저는 C++을 처음 접했습니다. 첨부 된 Compact Flash 카드 작성기에 원시 파일 (.img)을 작성하기 위해 Jni Call을 C++로 만드는 Java 응용 프로그램을 작성 중입니다. 아래는 내 C++ 코드입니다. 연결된 USB 드라이브를 찾고, createFile을 사용하여 Handle을 만들고, raw 이미지 (.img)를 장치에 씁니다. 결국 응용 프로그램은 Java JNI를 사용하여 호출됩니다.C++ createFile (Compact Flash Card Writer)
문제는 첨부 된 드라이브를 나열 할 수 있지만 createFile()을 사용하여 핸들을 생성하는 데 문제가 있다는 것입니다. 나는 오류 아래에 무엇입니까 :
Error 1 error C2660: 'getHandleOnVolume' : function does not take 2 arguments c:\users\omisorem.nov\documents\visual studio 2010\projects\diskrunner\diskrunner.cpp 71 1 DiskRunner
2 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPCWSTR" c:\users\omisorem.nov\documents\visual studio 2010\projects\diskrunner\diskrunner.cpp 86 23 DiskRunner
어떤 도움에 감사드립니다.
int main() {
// GetLogicalDrives returns 0 on failure, or a bitmask representing
// the drives available on the system (bit 0 = A:, bit 1 = B:, etc)
unsigned long driveMask = GetLogicalDrives();
int i = 0;
ULONG pID;
//cboxDevice->clear();
while (driveMask != 0)
{
if (driveMask & 1)
{
// the "A" in drivename will get incremented by the # of bits
// we've shifted
char drivename[] = "\\\\.\\A:\\";
drivename[4] += i;
cout << pID << "[%1:\\]" << drivename << endl;
}
driveMask >>= 1;
// cboxDevice->setCurrentIndex(0);
++i;
}
LPCTSTR volumeID = TEXT("D:");
int volumeID1 = int(volumeID);
hVolume = getHandleOnVolume(volumeID1, GENERIC_WRITE);
system("PAUSE");
return 0;
}
HANDLE getHandleOnVolume(int volume1, DWORD access)
{
HANDLE hVolume;
char volumename[] = "\\\\.\\A:";
volumename[4] += volume1;
hVolume = CreateFile("\\\\.\\F", access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hVolume == INVALID_HANDLE_VALUE)
{
cout <<"Partition does not exist or you don\'t have rights to access it"<<endl; // tesing
}
else {
cout << "Partition exists " << endl;
}
cout << volume1;
return hVolume;
}
왜 순수한 Java 방식을 사용하지 않을까요? 그것은 특히 Java 7부터 File IO를 완벽하게 지원합니다. – 01es
고마워요. 내가 한 적은 연구에서 Java는 JUSB 나 Java-USB API를 사용하는 것을 제외하고는 저급 호출을 지원하지 않는 것 같습니다. 구식이며 Windows 7과 호환되지 않습니다. 그러나 당신이 저를 가리킬 수 있다면 고맙겠습니다. 가능한 경우 순수한 자바 방향으로. – stdapsy