阅读:1222回复:1
如何编程获得Pocket Pc 2002的机器序列码?
我想获得Pocket Pc 2002机器序列码,因为每台Pocket Pc的序列码都是唯一的,这样就可以控制软件不外流,请问如何用Embedded C++来实现这个需求?我看到有的软件中就有这方面的信息,肯定是可以实现的。
|
|
沙发#
发布于:2004-02-12 06:28
There are two ways to obtain Serial number of a PPC, reading this SN directly from ROM or from data file. Here is the code for reading from file:
CString GetSerialNumber() { // Start CreateAssetFile.exe PROCESS_INFORMATION pi; if (!::CreateProcess(TEXT("\windows\CreateAssetFile.exe"), NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, π)) { m_strCompaqIpaqId = _T(""); m_strErrorMessage += _T("Cannot run \windows\CreateAssetFile.exe file."); return TEXT(""); } // Wait until CreateAssetFile.exe will be finished ::WaitForSingleObject(pi.hProcess, INFINITE); // Read data from cpqAssetData.dat file HANDLE hInFile; TCHAR strSN[65]; DWORD dwBytesRead; hInFile = CreateFile(TEXT("\windows\cpqAssetData.dat"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (hInFile == INVALID_HANDLE_VALUE) { m_strCompaqIpaqId = _T(""); m_strErrorMessage += _T("Cannot read \windows\cpqAssetData.dat file."); return TEXT(""); } SetFilePointer(hInFile, 976, NULL, FILE_BEGIN); memset(strSN, 0, 64 * sizeof(TCHAR)); ReadFile(hInFile, &strSN, 64, &dwBytesRead, NULL); CloseHandle(hInFile); return CString(strSN); } You can also download iPAQ SDK to read from ROM. Good luck. |
|