Hallo,
ich habe eine C++ dll zur ansteuerung einer Industriekamera in mein Projekt eingebunden via DllImport.
Das hat auch sehr gut funktioniert. DIe Kamera kommuniziert über Ethernet.
Die Funktionen der Dll sind bekannt und auch dokumentiert. Mein Problem liegt darin das bei einer benötigten Funktion ich als Rückgabe einen Fehlercode bekomme der besagt das ein Parameter falsch sei.
Die Funktione sieht wie folgt aus:
O3D2XX_API int __stdcall O3D2XXConnect ( HWND hCP, char * pIP, unsigned int iXMLPort, char * str_FWversion, char * str_SensorType )
Establish an Connection to the device.
Parameters:
hCP [IN] Window (handle) to send the messages to. If hcP != NULL the XML-RPC heartbeat is handled by the DLL If hcP == NULL the XML-RPC heartbeat mechanism is turned off by the device.
pIP [IN] IP address of the far end
iPort [IN] Port number of the far end
str_FWversion [OUT] device firmware version.
str_SensorType [OUT] device type.
Returns:
The Result. Success or the appropriate error state.
Eingebunden habe ich dll im Projektexplorer mit Add Existing File da es als Recource nicht möglich ist. Anschließend folgender Code:
Aufruf mit:
Als Rückgabe erhalte ich -7200:
Funktioniert der aufruf so oder mache ich hier Grundsätzlich etwas falsch? Meine Vermutung ist das es am Handle liegt, aber ich lasse mich gerne belehren.
MFG Markus
ich habe eine C++ dll zur ansteuerung einer Industriekamera in mein Projekt eingebunden via DllImport.
Das hat auch sehr gut funktioniert. DIe Kamera kommuniziert über Ethernet.
Die Funktionen der Dll sind bekannt und auch dokumentiert. Mein Problem liegt darin das bei einer benötigten Funktion ich als Rückgabe einen Fehlercode bekomme der besagt das ein Parameter falsch sei.
Die Funktione sieht wie folgt aus:
O3D2XX_API int __stdcall O3D2XXConnect ( HWND hCP, char * pIP, unsigned int iXMLPort, char * str_FWversion, char * str_SensorType )
Establish an Connection to the device.
Parameters:
hCP [IN] Window (handle) to send the messages to. If hcP != NULL the XML-RPC heartbeat is handled by the DLL If hcP == NULL the XML-RPC heartbeat mechanism is turned off by the device.
pIP [IN] IP address of the far end
iPort [IN] Port number of the far end
str_FWversion [OUT] device firmware version.
str_SensorType [OUT] device type.
Returns:
The Result. Success or the appropriate error state.
Eingebunden habe ich dll im Projektexplorer mit Add Existing File da es als Recource nicht möglich ist. Anschließend folgender Code:
[DllImport("O3D2xxCamera.dll")]
public static extern int O3D2XXConnect(IntPtr hwnd, IntPtr ip, UInt16 iXMLPort, IntPtr str_FWversion, IntPtr str_SensorType);
public static extern int O3D2XXConnect(IntPtr hwnd, IntPtr ip, UInt16 iXMLPort, IntPtr str_FWversion, IntPtr str_SensorType);
Aufruf mit:
IntPtr sensor = new IntPtr();
IntPtr firmware = new IntPtr();
IntPtr ip = Marshal.StringToBSTR("192.168.1.50");
O3D2XXConnect(this.Handle, ip, 8080, firmware, sensor));
IntPtr firmware = new IntPtr();
IntPtr ip = Marshal.StringToBSTR("192.168.1.50");
O3D2XXConnect(this.Handle, ip, 8080, firmware, sensor));
Als Rückgabe erhalte ich -7200:
#define O3D2XX_SENSOR_INVALID_PARAM -7200
the current parameter is not valid.
the current parameter is not valid.
Funktioniert der aufruf so oder mache ich hier Grundsätzlich etwas falsch? Meine Vermutung ist das es am Handle liegt, aber ich lasse mich gerne belehren.
MFG Markus