BOOL GetVolumeInformation( LPCTSTR lPRootPathName,
LPTSTR lpVolumeNameBuffer,
DWord nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize );
DWORD dwSerialNum;
GetVolumeInformation("A://",NULL,NULL,&dwSerialNum,NULL,NULL,NULL,NULL);
……
if(file.Open("Logo.ini",CFile::modeReadWrite)==FALSE)
{
AfxMessageBox("請將正版鑰匙盤插入到軟驅!");
MakeKey();
}
else
{
file.Read(logo,20);
file.Close();
DWORD LogoNum=atol(logo);
GetVolumeInformation("C://",NULL,NULL,&dwIDESerial,NULL,NULL,NULL,NULL);
if(LogoNum!=dwIDESerial)
{
AfxMessageBox("請將正版鑰匙盤插入到軟驅!");
MakeKey();
}
else
m_bCanRun=true;
}
……
if(m_bCanRun==true)
{
m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
}
else
PostQuitMessage(0);
GetVolumeInformation("A://",NULL,NULL,&dwSerialNum,NULL,NULL,NULL,NULL);
if(dwSerialNum==SerialNum)//SerialNum就是我們預先獲取的作為正版標識的序列號
{
GetVolumeInformation("C://",NULL,NULL,&dwIDESerial,NULL,NULL,NULL,NULL);
ltoa(dwIDESerial,logo,10);
while(logo[i]!=’/0’)
i++;
……
file.Open("Logo.ini",CFile::modeCreate CFile::modeReadWrite);
file.Write(logo,i);
file.Close();
AfxMessageBox("已通過認證,下次使用時不必再插入鑰匙軟盤!");
m_bCanRun=true;
}
else
{
AfxMessageBox("請插入正版鑰匙軟盤再執行本程序!");
m_bCanRun=false;
}
新聞熱點
疑難解答