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;
}
新闻热点
疑难解答