hdhelper.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:1k
- //***************************************************/
- // hdhelper.cpp */
- //***************************************************/
- #include "stdAfx.h"
- #include "hdhelper.h"
- //根据本地环境来获取Agent唯一标识.
- BOOL GetAgentSerialNo(LPSTR pserialno, const int nmaxbufsize)
- {
- char path[16],
- filesysname[32];
-
- DWORD dwVolumeSerialno = 0,
- dwMaxComplen = 0,
- dwFileSysFlags = 0;
-
- DWORD dwSerialnos = 0;
-
- if(!nmaxbufsize || !nmaxbufsize) return FALSE;
- int i = 'C';
- /*for(int i = 'C'; pserialno && i < 'Z' + 1; ++i)*/
- {
- memset(path, 0x0, sizeof(path));
- memset(filesysname, 0x0, sizeof(filesysname));
- _snprintf(path, sizeof(path), "%c:\", i);
-
- if(GetVolumeInformation(path, NULL, 0,
- &dwVolumeSerialno, &dwMaxComplen,
- &dwFileSysFlags, filesysname, sizeof(filesysname)))
- {
- dwSerialnos += (dwVolumeSerialno >> 4);
- dwSerialnos ^= (dwFileSysFlags << 4);
- }
- //else break;
- }
- _snprintf(pserialno, nmaxbufsize, "%x", dwSerialnos);
- return TRUE;
- }