我在vc下调试程序出现下列错误 'GetStringUTFChars' : function does not take 3 parameters error C2660: 10
以下是我的程序JNIEXPORTjbooleanJNICALLJava_readsector_ReadSector_ReadSector(JNIEnv*env,jobje...
以下是我的程序
JNIEXPORT jboolean JNICALL Java_readsector_ReadSector_ReadSector(JNIEnv *env, jobject obj, jstring _chDriveName, jcharArray pBuffer, jint _nSector)
{
//char *_pp;
char *_pBuffer;
//_pp = (char*) env->GetCharArrayElements(env, pBuffer, 0);
_pBuffer = (char*) env->GetStringUTFChars(env, pBuffer, 0);
char Buffer[512];
HANDLE hDevice;
DWORD dwBytesReaden;
sprintf(Buffer,"\\\\.\\%c:",_chDriveName);
hDevice =
CreateFile(Buffer, // drive to open.
GENERIC_READ,
FILE_SHARE_READ | // share mode.
FILE_SHARE_WRITE,
NULL, // default security attributes.
OPEN_EXISTING, // disposition.
0, // file attributes.
NULL); //
if(hDevice==INVALID_HANDLE_VALUE)//if Error Openning a drive.
{
return FALSE;
}
//Move the read pointer to the right sector.
if(SetFilePointer(hDevice,
_nSector*512,
NULL,
FILE_BEGIN)==0xFFFFFFFF)
return FALSE;
//Read the Sector.
ReadFile(hDevice,
_pBuffer,
512,
&dwBytesReaden,
0);
env->ReleaseStringUTFChars(env, pBuffer, _pBuffer);
//env->ReleaseCharArrayElements(env, pBuffer, _pp);
//if Error reading the sector.
if(dwBytesReaden!=512)
return FALSE;
return TRUE; 展开
JNIEXPORT jboolean JNICALL Java_readsector_ReadSector_ReadSector(JNIEnv *env, jobject obj, jstring _chDriveName, jcharArray pBuffer, jint _nSector)
{
//char *_pp;
char *_pBuffer;
//_pp = (char*) env->GetCharArrayElements(env, pBuffer, 0);
_pBuffer = (char*) env->GetStringUTFChars(env, pBuffer, 0);
char Buffer[512];
HANDLE hDevice;
DWORD dwBytesReaden;
sprintf(Buffer,"\\\\.\\%c:",_chDriveName);
hDevice =
CreateFile(Buffer, // drive to open.
GENERIC_READ,
FILE_SHARE_READ | // share mode.
FILE_SHARE_WRITE,
NULL, // default security attributes.
OPEN_EXISTING, // disposition.
0, // file attributes.
NULL); //
if(hDevice==INVALID_HANDLE_VALUE)//if Error Openning a drive.
{
return FALSE;
}
//Move the read pointer to the right sector.
if(SetFilePointer(hDevice,
_nSector*512,
NULL,
FILE_BEGIN)==0xFFFFFFFF)
return FALSE;
//Read the Sector.
ReadFile(hDevice,
_pBuffer,
512,
&dwBytesReaden,
0);
env->ReleaseStringUTFChars(env, pBuffer, _pBuffer);
//env->ReleaseCharArrayElements(env, pBuffer, _pp);
//if Error reading the sector.
if(dwBytesReaden!=512)
return FALSE;
return TRUE; 展开
展开全部
GetStringUTFChars中的第一个参数env删掉就可以了!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询