[SOLVED] Connection to instrument via COM fails lazarus / 34-Windows ---------------------------------------------------------------------- Eclipticon · 2014-08-22 08:02 Good morning, in a Lazarus project, I am using a COM interface to connect to an external device that is connected to the computer running the software via TCP/IP. I am posting this, because on one system this connection fails, mysteriously. From the manufacturer, I have received an instrument.dll and an instrument.tlb. Unfortunately, details and code are subject to a confidentiality agreement, so I can only provide pseudocode. I have two minimal examples, one on Free Pascal: Code: [Select]uses    Instrument_TLB; // Imported via the Lazarus "Import Type Library" function from the .tlb or the .dll [...] procedure TForm1.FormCreate(Sender: TObject); begin   AInstrument := CoInstrument.Create;   if AInstrument.Connected then ... end; and one on Visual Basic, provided by the manufacturer: Code: [Select]Private Sub Form_Load()    Set theInstrument = New Instrument    If theInstrument.Connected Then ... End Sub This VB6 project has the instrument.dll as a reference. Both the executables as well als the instrument.dll are 32bit. The behaviour on different computers is as follows (supplemented with information from Sysinternals Process Explorer): System A (Windows XP, 32bit, used for compilation): Both the FP and the VB executable work as expected, a connection can be established. In Process Explorer, both executables have one thread with instrument.dll and the TCP/IP connection can be seen to be up.System B (Windows 7, 64bit): Both the FP and the VB executable work as expected, a connection can be established. Process Explorer was not used.System C (Windows 7, 64bit): The VB executable works as expected, a connection can be established. In Process Explorer the VB executable has one thread with instrument.dll and the TCP/IP connection can be seen to be up. The FP executable can NOT connect, there are two threads with instrument.dll and no TCP/IP connection seen in Process Explorer. What I just do not get is why the minimal example with VB6 works fine while the (essentially identical) example on FP does not work on this one system. I know that based on the little information I am able to give, no one can come up with a "solution" - however, advice on how to investigate this problem further, what tools to use for debugging would be highly appreciated! Thanks for your time. ---------------------------------------------------------------------- Laksen · 2014-08-22 08:11 Do you know what the difference between system b and c is? Did you compile for i386 or x86_64? ---------------------------------------------------------------------- Eclipticon · 2014-08-22 08:16 Quote from: Laksen on August 22, 2014, 10:11:23 amDo you know what the difference between system b and c is? There are countless differences in hardware and software on systems B and C - which could explain if both the VB6 Test and the FP Test fail, but as the VB6 test works, the interface itself seems to be ok ... Quote from: Laksen on August 22, 2014, 10:11:23 amDid you compile for i386 or x86_64? It was compiled on a i386 system, so i386. ---------------------------------------------------------------------- Laksen · 2014-08-22 14:39 One of the most obvious would be to know if the regional settings of system b and c are different? Comma seperator, etc. ---------------------------------------------------------------------- Eclipticon · 2014-08-22 15:43 Quote from: Laksen on August 22, 2014, 04:39:35 pmOne of the most obvious would be to know if the regional settings of system b and c are different? Comma seperator, etc. I had not checked this before, but they are identical - both systems B and C are set to "German (Germany)". ---------------------------------------------------------------------- Never · 2014-08-22 15:49 maybe firewall / antivirus settings also compare the hosts files on both systems ---------------------------------------------------------------------- Eclipticon · 2014-08-22 16:37 Hi, it was not the firewall, but your advice checking the firewall made me have a look at the IP addresses again - it turns out there was 3 times the correct one in the registry and one time a wrong one (in HKLM\SOFTWARE\WOW6432Node\...). Correcting the wrong one AND starting the program in Windows 7 compatibility mode (on windows 7?) fixed the error. I just need to understand now, why ... especially why the VB test program runs without problems. ---------------------------------------------------------------------- Never · 2014-08-22 17:14 i'm glad i was helpfull. just a possibility ................. your server costandly brodcasting  a message on a specific port (usualy udp port) then the vb app just need to listen to the correct port to start the communication but......... this is just a quess