Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting a VB DLL declaration and function
Message
De
19/04/2007 08:54:42
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/04/2007 07:30:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01217662
Message ID:
01217709
Vues:
10
This message has been marked as a message which has helped to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform