Forum > Windows
COM-Client
kupferstecher:
Importtl worked, I used the following command line:
Path\importtl.exe "Path\NNNNCom.exe"
This created a Pascal unit containing all the types and so on, so I can include the unit in the uses of my project. Further questions:
1. I'm not so clear now, how the Com-Server, that I wan't to communicate with, is started. Should it already run when I try to "connect" with the client, or is there an automatic starting mechanism when I instantiate a COM object?
2. What would the CoCreateInstance() (c++) equivalent be in Pascal? I found the CreateComObject() function in avra's link, could it be that?
@avra, thanks for the link, I have a look, but seems to be a bigger project :)
@marcov: Also thanks! About the bug reports, what keywords would you search for, I didn't find anything related so far.
Edit: Removed brand name.
marcov:
1. Afaik the dll should be registered together with the GUID using the regsvr(32) binary. (admin box in modern windows afaik)
Of course there is always 32-bit vs 64-bit to look out for.
2.
--- Code: --- function CreateComObject(const ClassID : TGUID) : IUnknown;
begin
OleCheck(CoCreateInstance(ClassID,nil,CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,IUnknown,result));
end;
--- End code ---
So basically it is a simple wrapper, olecheck changes COM related return values into exceptions I think.
bugreports: I don't know if this all surived the mantis -> gitlab changesover, but the old bugreports were tagged as "COM". I think servers are harder than clients though.
kupferstecher:
Ok, great.
1. OK, I make some tests first.
2. Understood!
Thanks so far!
kupferstecher:
Me, again..
After some tests I'm still stuck with an error, EOleSysError: Class not registered. It occurs in the moment the interface is created (Its the first line of code). Compilation works fine.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---DeviceList:= CreateComObject(IID_INNNNDeviceList) as INNNNDeviceList;I wonder if I have to load the library before something within the library is refered to.
The error is the same for 64bit and 32bit (crosscompiled on 64bit Lazarus) applications. Also I tested the c++ example code (snippet in post 1) with Visual Studio and that works. So the automatic loading of the COM server obviously can work. The registry stuff was probably done by the installer of the software and driver package of the device that I want to connect with.
I also tried to compile the c++ example code with gcc, but it doesn't support the syntax #import "libid:... Maybe there is some special compiler magic involved with this command?
Anyone any idea how to get it working under Lazarus? Do I have to load the executable somehow? As far as I understand the server is a exe and not a dll.
Thanks!
Here the code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit uCOMClient;{$mode ObjFPC}{$H+} interface uses Classes, SysUtils, ComObj, NNNNCOMLib_1_12_TLB; Procedure GetDevices; var DeviceList: INNNNDeviceList; implementation Procedure GetDevices;begin DeviceList:= CreateComObject(IID_INNNNDeviceList) as INNNNDeviceList; //EOleSysError writeln('Available Devices: ',DeviceList.Count); DeviceList:= nil; //automatically releasedend; end.
Edit: Removed brand name.
marcov:
Afaik coinitialize is done by the comobj unit entry code, so this should simply work.
Navigation
[0] Message Index
[#] Next page
[*] Previous page