I'm a beginner in Windows Programming or I'll say I don't know much at all.
In my program, I'm using JNI to import a DLL file written in Windows API into my Java program.
In the C program that direct the JNI variables into DLL Functions, I'm required to convert jbyte* which is similar to byte * to LPBYTE as the function parameters are of LPBYTE type.
I've tried the code below as a separate running program and it works.
Code:
byte t2 ='4';
printf( "number value : %c\n", t2 );
printf( "number address : %p\n", &t2 );
LPBYTE test = new byte[256];
test = &t2;
printf("test address : %p\n",test);
printf("test value : %c\n\n",*test);
However, when I port it into my real program using this code:
Code:
jbyte *lpbMRZ_local = (*env)->GetByteArrayElements(env, lpbMRZ, 0);
jsize len = (*env)->GetArrayLength(env, lpbMRZ);
int i=0, j = 0;
DWORD slen=len;
printf("Length = %d %lu\n",len, slen);
for( i=0; i<len; i++)
printf("%lu ",lpbMRZ_local[i]);
printf("\n");
LPBYTE lpbMRZ_lp = &lpbMRZ_local;
I get this error, referring to
Code:
C:\eclipse\workspace\ePPTestApp\src>cl -IC:\j2sdk1.4.2_12\include -IC:\j2sdk1.4.2_12\include\win32 -LD JavaBACInterface.c -Febacinterface.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
JavaBACInterface.c
JavaBACInterface.c(46) : error C2275: 'LPBYTE' : illegal use of this type as an expression
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(150) : see declaration of 'LPBYTE'
JavaBACInterface.c(46) : error C2146: syntax error : missing ';' before identifier 'lpbMRZ_lp'
JavaBACInterface.c(46) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
JavaBACInterface.c(46) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
JavaBACInterface.c(46) : error C2143: syntax error : missing ';' before 'identifier'
JavaBACInterface.c(46) : error C2065: 'lpbMRZ_lp' : undeclared identifier
JavaBACInterface.c(46) : warning C4047: '=' : 'int' differs in levels of indirection from 'jbyte ** '
I've been trying of all sort of ways to perform the conversion from byte* to LPBYTE for the week. And this is my last resort. I don't even know what's wrong.
So, may I know how to convert common byte* into LPBYTE?
P/S: I post the question here as it involves LPBYTE, windows api data type. Please inform me if I should post elsewhere.