|
请wince高手帮忙编译一小段程序做成可执行文件
[复制链接]
我的目的是获取cf卡的id,下面是一段我在eeworld上找到的程序,应该没有error,但是我没有ce的开发环境,所以在这里请高手帮忙,如果生成后请发到我的邮箱okimrong@hotmail.com , 这个邮箱也是我的msn! 代码如下:
#include
typedef struct _STORAGE_IDENTIFICATION {
DWORD dwSize;
DWORD dwFlags;
DWORD dwManufactureIDOffset;
DWORD dwSerialNumOffset;
} STORAGE_IDENTIFICATION, *PSTORAGE_IDENTIFICATION;
TCHAR tzCFCardID[22];
TCHAR tzError[50];
HANDLE hCard = CreateFile(TEXT("DSK3:"), GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(hCard)
{
int i = 0;
PSTORAGE_IDENTIFICATION pStoreInfo;
pStoreInfo=(STORAGE_IDENTIFICATION *)LocalAlloc(LMEM_ZEROINIT,3000);
DWORD dwGetBytes;
if (DeviceIoControl(hCard,CTL_CODE(0x0007, 0x0709, METHOD_BUFFERED, FILE_ANY_ACCESS),NULL,0,(LPVOID)pStoreInfo,3000,&dwGetBytes,NULL)!=FALSE)
{
if(dwGetBytes > 0)
{
i = 0;
int j = 0;
if(pStoreInfo->dwSerialNumOffset < dwGetBytes)
{
BYTE* SerialNo=(((BYTE *)pStoreInfo)+pStoreInfo->dwSerialNumOffset);
while (SerialNo!=0 && i<(int)(dwGetBytes-pStoreInfo->dwSerialNumOffset) && i<22)
{
if(SerialNo < '0' || SerialNo > 'z')
{
j++;
}
else
{
tzCFCardID[i - j]=(TCHAR)SerialNo;
}
i++;
}
}
tzCFCardID[i - j]=0;
}
}
else
{
wsprintf(tzError, TEXT("Fail to read Card ID, error number is:%lu!"), GetLastError());
AfxMessageBox(tzError);
LocalFree(pStoreInfo);
CloseHandle(hCard);
return ;
}
LocalFree(pStoreInfo);
CloseHandle(hCard);
AfxMessageBox(tzCFCardID);
}
|
|