Je suis coincé avec un fichier une fonction importé d'un fichier DLL que je ne comprend pas comment l'inclure dans mon programme en PureBasic.
Je trouve 2 explications sur la fonction que je voudrais utilisé
1 - En Visual Basic
' allocate library handle 3
Declare Function cnc_allclibhndl3 Lib "FWLIB32.DLL" _
(ByVal ip As String, ByVal port As Short, ByVal timeout As Integer, ByRef FlibHndl As Integer) As Short
2 -En Visual C#
/* allocate library handle 3 */
[DllImport("FWLIB32.dll", EntryPoint="cnc_allclibhndl3")]
public static extern short cnc_allclibhndl3( [In,MarshalAs(UnmanagedType.AsAny)] Object ip,
ushort port,int timeout, out ushort FlibHndl);
Et voici mon essais de code:
Code : Tout sélectionner
Enumeration
#Bibliotheque
EndEnumeration
Global Ip.s="192.168.105.8"
Global Port.w = 8193
Global handle.i
source.s = GetCurrentDirectory()
Fichierdll.s = source + "Fwlib32.dll"
If OpenLibrary(#Bibliotheque,Fichierdll)
Ret.w=CallFunction(#Bibliotheque,"cnc_allclibhndl3",@Ip,@Port,2,*handle)
Debug Ret
EndIf
Je pense que j'utilise pas bien les arguments car je n'ais pas ce que je recherche en résultat.
Pourriez vous m'aiguiller dans les arguments, comment je doit les interprétés
documentation sur la procédure:
Declaration
#include "fwlib32.h" or "fwlib64.h"
FWLIBAPI short WINAPI cnc_allclibhndl3(const char *ipaddr, unsigned short port, long timeout, unsigned short *FlibHndl);
Description
Allocates the library handle and connects to CNC that has the specified IP address or the Host Name.
Before executing this function, set the IP address and the port number of the FOCAS1/Ethernet (TCP) or FOCAS2/Ethernet (TCP) function on the CNC side correctly.
Arguments
ipaddr [ in ]
Specify character string of CNC's IP address or Host Name to connect.
(Ex. "192.168.0.1" or "CNC-1.FACTORY")
port [ in ]
Specify port number of the FOCAS1/Ethernet or FOCAS2/Ethernet (TCP) function.
timeout [ in ]
Specify seconds for timeout. If specify 0, timeout process is ignored and the library functions wait infinity.
The best timeout value is different according as system. For example, in case of the hi-speed network system, 10 seconds is sufficient for timeout. But in case of relaying by low-speed telephone line, more than 60 seconds is well for timeout. So you must specify the timeout value after the measurement of your communication time.
FlibHndl [ out ]
Specify pointer to variable including the library handle.
See "Library handle" for details.