- UID
- 38377
- 积分
- 135
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-3-25
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- #include "StdAfx.h"
- #include "VolumeManagement.h"
- #pragma region //DriveTypeFlags
- struct // DriveType
- {
- UINT type; // return code from GetDriveType
- LPCTSTR name; // ascii name
- }
- DriveTypeFlags [] =
- {
- { DRIVE_UNKNOWN, _T("Unknown") },
- { DRIVE_NO_ROOT_DIR, _T("Invalid path") },
- { DRIVE_REMOVABLE, _T("Removable") },
- { DRIVE_FIXED, _T("Fixed") },
- { DRIVE_REMOTE, _T("Network drive") },
- { DRIVE_CDROM, _T("CD-ROM") },
- { DRIVE_RAMDISK, _T("RAM disk") },
- { 0, NULL}
- };
- #pragma endregion
- #pragma region //driveserialno
- //(crpdriveserialno "c")
- int DriveSerialNo(void)
- {
- //Declare string variables
- CString str;
- struct resbuf *pArgs =acedGetArgs ();
- if(pArgs == NULL)
- str = _T("C");
- else
- {
- if(pArgs->restype == RTSTR)
- str = pArgs->resval.rstring;
- else
- str = _T("C");
- }
- str.Truncate(1);
- str = str + _T(":\\");
- DWORD VolumeSerialNumber = 0;
- GetVolumeInformation(str, NULL, 0, (DWORD *)&VolumeSerialNumber, NULL, NULL, NULL, 0 );
- if (VolumeSerialNumber != 0)
- {
- TCHAR Result[10] = {0};
- _sntprintf(Result , sizeof(TCHAR)*10 , _T("%X") , VolumeSerialNumber );
- acedRetStr(Result);
- }
- else
- acedRetNil();
- return (RSRSLT) ;
- }
- #pragma endregion
- #pragma region //filesystem
- //(crpfilesystem "c")
- int FileSystem(void)
- {
- CString str;
- struct resbuf *pArgs =acedGetArgs () ;
- //get the resbuf from lisp, test validity
- if(pArgs == NULL)
- str = _T("C");
- else
- {
- if(pArgs->restype == RTSTR)
- str = pArgs->resval.rstring;
- else
- str = _T("C");
- }
- str.Truncate(1);
- str = str + _T(":\\");
- TCHAR FileSystem[MAX_PATH] = {0};
- GetVolumeInformation(str, NULL, 0, NULL, NULL, NULL, FileSystem, sizeof(TCHAR)*MAX_PATH);
- if (_tcsclen(FileSystem) != NULL)
- acedRetStr(FileSystem);
- else
- acedRetNil();
- return (RSRSLT) ;
- }
- #pragma endregion
- #pragma region //drivetype
- //(crpdrivetype "c")
- int DriveType(void)
- {
- //
- CString str;
- CString DriveType;
- //
- struct resbuf *rb = NULL;
- //
- struct resbuf *pArgs =acedGetArgs () ;
- if(pArgs == NULL)
- str = _T("C");
- else
- {
- if(pArgs->restype == RTSTR)
- str = pArgs->resval.rstring;
- else
- str = _T("C");
- };
- //
- str.Truncate(1);
- str += _T(":\\");
- UINT uDriveType = GetDriveType(str);
- for (int i=0; DriveTypeFlags.name; i++)
- {
- if (uDriveType == DriveTypeFlags.type)
- {
- DriveType = DriveTypeFlags.name;
- break;
- }
- }
- //
- if (!DriveType.IsEmpty())
- acedRetStr(DriveType);
- else
- acedRetNil();
- return (RSRSLT) ;
- }
- #pragma endregion
- #pragma region //drives
- //(crpdrives)
- int Drives(void)
- {
- struct resbuf* pRbRet = acutNewRb(RTT);
- struct resbuf* pRbTail;
- pRbTail = pRbRet;
- TCHAR szBuffer[1024] = {0};
- GetLogicalDriveStrings(1024, szBuffer);
- TCHAR *drv = szBuffer;
- while (*drv)
- {
- pRbTail = pRbTail->rbnext = acutBuildList(RTSTR,drv,RTNONE);
- drv = &drv[_tcslen(drv) + 1];
- }
- acedRetList(pRbRet->rbnext);
- acutRelRb(pRbRet);
- return (RSRSLT) ;
- }
- #pragma endregion
|
|