You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
By george youve done it!!! first crack and all
I think i had tried every combination except that one, thats the only problem - me
This will definately come in handy over and over, thanks very much Lance - enjoy the weekend!
What specific part are you having problems with? Parameter declaration problems, missing export, or...?
The BYVAL DWORD parameter should work fine provided you pass the string BYVAL from VB (The BYVAL of a dynamic string in VB forces VB to translate VB's internal UNICODE string to a null-terminated ANSI string, and it then passes a pointer to that).
Therefore, your BYVAL DWORD should receive the pointer address fine as long as you are passing BYVAL dynamicstring$.
Something like this:
Code:
DECLARE FUNCTION CRC32HASH LIB "pbcrc32.dll" _
ALIAS "CRC32HASH" (BYVAL Buf AS STRING, _
BYVAL lBuf AS LONG, Crc AS LONG) AS LONG
Ive put together a little DLL in PB simply to create a CRC32 hash based on the CRC32 code floating around this forum. I can call it easily from PB, but I need to also call it from a VB app...
Here is the function exported from the PB DLL:
Code:
FUNCTION CRC32HASH (BYVAL ptrBuffer AS DWORD, BYVAL lenBuffer AS LONG, szReturn AS LONG) EXPORT AS LONG
Here is how I call it in PB:
Code:
#COMPILE EXE
#INCLUDE "win32api.inc"
DECLARE FUNCTION CRC32HASH Lib "pbcrc32.dll" ALIAS "CRC32HASH" (BYVAL ptrBuffer AS DWORD, BYVAL lenBuffer AS LONG, szReturn AS LONG) AS LONG
FUNCTION PBMAIN() AS LONG
ON ERROR RESUME NEXT
Dim MyString As String
Dim ResultCrc AS Long
MyString = "Test" & CHR$(0) & "Test" 'Note - cant use ASCIIZ, as string can have nullchars in it
Dim Result AS LONG
Result = CRC32HASH(STRPTR(MyString), LEN(MyString), ResultCrc)
MSGBOX "Result=" & STR$(Result) & ", CRC=" & HEX$(ResultCrc) 'Should return 45862144
END FUNCTION
Ive been trying for the last few hours to call it from VB, but none of my combinations have worked. It seems straight-forward enough, just need to crack the combination! Any ideas anyone?
[This message has been edited by Wayne Diamond (edited August 31, 2001).]
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: