Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting a VB DLL declaration and function
Message
De
19/04/2007 09:19:22
 
 
À
19/04/2007 08:54:42
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01217662
Message ID:
01217732
Vues:
8
Thanks Cetin. Sergey has also suggested the SYS(2600) function and I seem to be a step closer :)


>>Hi All
>>
>>I'm struggling with trying to convert a bit of VB code to VFP. The VB code has this DLL declaration:
>>
>>
>>Private Declare Sub RtlMoveMemory Lib "kernel32" (ByVal hpvDest As Any, ByVal hpvSource As Any, ByVal nBytes As Long)
>>
>>
>>I have translated this declare into:
>>
>>
>>DECLARE INTEGER RtlMoveMemory IN KERNEL32.DLL ;
>>  STRING hpvDest, ;
>>  LONG hpvSource, ;
>>  LONG nBytes
>>
>>
>>Then the VB code calls this function as follows:
>>
>>
>>Dim bytePhrase(500) As Byte
>>*'Store the string pointer as a byte in the bytePhrase array
>>RtlMoveMemory VarPtr(bytePhrase(0)), lngStrAddress, 500
>>*'Convert from a byte to string
>>ByteToString = StrConv(bytePhrase, vbUnicode)
>>
>>
>>Where lngStrAddress is a pointer to a memory address which contains some text as single-byte or double-byte characters. eg lngStrAddress = 165270112.
>>
>>The VB code above uses the RtlMoveMemory call to get at the data contained at this address and convert it using VarPtr() and StrConv() to a string but I cannot seem to make that work in VFP :/
>>
>>Anybody know what to do?
>
>
>Declare RtlMoveMemory In WIN32API ;
>	INTEGER @DestNumeric, ;
>	STRING @pVoidSource, ;
>	INTEGER nLength
>
>lnValue = 0
>lcStr = bintoc(1200,'4RS')
>lnSize = 4
>RtlMoveMemory(@lnValue, m.lcStr, m.lnSize)
>? m.lnValue
>However in VFP there are tons of functions now to use in place of RtlMoveMem, like createbinary(),strconv(),bintoc(),ctobin(),sys(2600) ...
>Cetin
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform