Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: DllCall DLL Return Pointer IntControl 32 Read QR Codes Images QRCodeDecodeImageFile Qrcode SDK StrFromMemAddr lstrcpynA
The QRCodeDecodeImageFile() returns an integer that is supposed to be a pointer to the result, but I don't know what to do with it. Any thoughts? My Code:
QRDLL = DirScript():"QRCodeDecodeDll.dll" QR = DllLoad(QRDLL) InFile = "C:\QR.BMP" bData = BinaryAlloc(8192) ;buffer for the data, not that I know how to get it there BinaryEODSet(bData,8192) bCount = BinaryAlloc(4) BinaryEODSet(bCount,4) pCount = IntControl(42,bCount,0,0,0) Result = DllCall(QR,long:"QRCodeDecodeImageFile",lpstr:inFile,long:pCount) display(1,"Result",Result) ; shows an integer Count=BinaryPeek4(bCount,0) display(1,"Count",Count) ; shows 1 for an image with one QRCode ;need to do something here to actually extract the data DllCall(QR,long:"QRCodeFree",long:Result,long:Count)The DLL Documentation:
Structure of the QRCode decoding result: typedef struct tagResult { BYTE *pData; //result of decoding result int nSize; //data length int xPos; //Left top position of barcode at image int yPos; // Left top position of barcode at image } Result; QRCodeDecodeImageFile The QRCodeDecodeImageFile function read QRCode figure from image and decode it to text or binary data. Result * __stdcall QRCodeDecodeImageFile(char *pImageFile,int *pCount); Parameters: pImageFile char * [in] the image file containing QRCode figure, it can be BMP,GIF,PNG,JPG or TIF formats. pCount int [out] the barcodes the function found and the number of the result returnd. The pointer need be allocate memory before calling the function. Return values Result *, the first result pointer. If having more barcodes, move the pointer to get the next barcode result. NULL decode failure or no barcode found.Reference: http://www.aipsys.com/order/buy-2d-barcode-encoder-sdk/buy-qrcode-encoder-sdk.html
;typedef struct tagResult ;{ ;BYTE *pData; //result of decoding result ;int nSize; //data length ;int xPos; //Left top position of barcode at image ;int yPos; // Left top position of barcode at image ;} Result; QRDLL = DirScript():"QRCodeDecodeDll.dll" QR = DllLoad(QRDLL) InFile = "C:\QR.BMP" bCount = BinaryAlloc(4) Result = DllCall(QR,long:"QRCodeDecodeImageFile",lpstr:inFile,lpBinary:bCount) Count=BinaryPeek4(bCount,0) BinaryFree( bCount) Display(1,"Count",Count) ; shows 1 for an image with one QRCode ; Get first QRCode pData = IntControl (32, Result, 'LONG', 0, 0) nSize = IntControl (32, Result+4, 'LONG', 0, 0) xPos = IntControl (32, Result+8, 'LONG', 0, 0) yPos = IntControl (32, Result+12, 'LONG', 0, 0) Pause('QRCodeDecodeImageFile Results', 'pData = ':pData:@LF:'nSize = ':nSize:@LF:'xPos = ':xPos:@LF:'yPos = ':yPos) ; Display the Data Data="" For N = 0 To nSize-1 Data = Data:Num2Char(IntControl(32, pData+N, 'BYTE', 0, 0)) Next Message("Data",Data) DllCall(QR,long:"QRCodeFree",long:Result,long:Count)
Whether this is a better approach or not is open to discussion but it is another approach. You may need to tweak it a bit depending on where or not your data has a null terminator or whether or not the returned nSize includes the null terminator as part of its total.
; MemAddr - memory address ; nSize - number of bytes allocated at MemAddr #DefineFunction StrFromMemAddr(MemAddr, nSize) hBin = BinaryAlloc(nSize+1) x = DllCall("Kernel32.dll",long:"lstrcpynA",lpbinary:hBin, long:MemAddr, long:nSize) BinaryEodSet(hBin,nSize) strResult = BinaryPeekStr(hBin, 0, nSize) BinaryFree(hBin) Return strResult ; ANSI string returned #EndFunction
Article ID: W17787
Filename: DLL Pointer Problem .txt
File Created: 2013:03:13:13:31:58
Last Updated: 2013:03:13:13:31:58