4、定义u_sysinfo的实例变量。
public:
string cpuid,cpuprovider
string filesystem,volumename
ulong VolumeSerialNumber,MaxComponentLength,FileSystemFlags
long dlength,dmemoryload,dtotalphys,davailphys,dtotalpagefile
long davailpagefile,dtotalvirtual,davailvirtual
ulong dwoemid,dwpagesize,lpminappaddress,lpmaxappaddress,dwactiveprocessormask
ulong dwnumberofprocessors,dwprocessortype,dwallocationgranularity,dwreserved
ulong sectorspercluster,bytespersector,numberoffreeclusters,totalnumberofclusters
ulong mbtotal,mbfree
5、定义u_sysinfo的局部外部函数
PUBLIC FUNCTION ulong GetComputerName(ref string lpBuffer,ref ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetComputerNameA"
PUBLIC FUNCTION ulong GetDriveType(string nDrive) LIBRARY "kernel32.dll" ALIAS FOR "GetDriveTypeA"
FUNCTION ulong GetDiskFreeSpace(ref string lpRootPathName,ref ulong lpSectorsPerCluster,ref ulong
lpBytesPerSector,ref ulong lpNumberOfFreeClusters,ref ulong lpTtoalNumberOfClusters)
LIBRARY "kernel32.dll" ALIAS FOR "GetDiskFreeSpaceA"
PUBLIC FUNCTION ulong GetTickCount() LIBRARY "kernel32.dll"
PUBLIC Subroutine GetSystemInfo(ref ws_info lpSystemInfo) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong waveOutGetNumDevs() LIBRARY "winmm.dll"
PUBLIC FUNCTION ulong WNetGetUser(ref string lpName,ref string lpUserName,ref ulong lpnLength)
LIBRARY "mpr" ALIAS FOR "WNetGetUserA"
PUBLIC FUNCTION ulong GetSystemMetrics(ulong nIndex) LIBRARY "user32.dll"
PUBLIC FUNCTION ulong GetWindowsDirectory(ref string lpBuffer,ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetWindowsDirectoryA"
PUBLIC FUNCTION ulong GetSystemDirectory(ref string lpBuffer,ulong nSize) LIBRARY "kernel32.dll"
ALIAS FOR "GetSystemDirectoryA"
PUBLIC FUNCTION ulong GetTempPath(ulong nBufferLength,ref string lpBuffer) LIBRARY "kernel32.dll"
ALIAS FOR "GetTempPathA"
PUBLIC FUNCTION ulong GetKeyboardType(ulong nTypeFlag) LIBRARY "user32.dll"
PUBLIC FUNCTION ulong QueryPerformanceFrequency(ref double lpFrequency) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong QueryPerformanceCounter(ref ulong lpPerformanceCount) LIBRARY "kernel32.dll"
//PUBLIC FUNCTION ulong EnumPrinterDrivers(ref string pName,ref string pEnvironment,ulong Level,ref
Byte pDriverInfo,ulong cdBuf,ref ulong pcbNeeded,ref ulong pcRetruned) LIBRARY
"winspool.drv" ALIAS FOR "EnumPrinterDriversA"
PUBLIC Subroutine GlobalMemoryStatus(ref ws_memory lpBuffer) LIBRARY "kernel32.dll"
//FUNCTIONon ulong GlobalReAlloc(ulong hMem,ulong dwBytes,ulong wFlags) LIBRARY "kernel32.dll"
PUBLIC FUNCTION ulong RegOpenKey(ulong hKey,ref string lpSubKey,ref ulong phkResult) LIBRARY
"advapi32.dll" ALIAS FOR "RegOpenKeyA"
PUBLIC FUNCTION ulong RegCloseKey(ulong hKey) LIBRARY "advapi32.dll"
PUBLIC FUNCTION ulong RegQueryValueEx(ulong hKey,ref string lpValueName,ulong lpReserved,ref ulong
lpType,ref long lpData,ref ulong lpcbData) LIBRARY "advapi32.dll" ALIAS FOR
"RegQueryValueExA"
//Function ulong EnumDisplaySettingsA(ulong xx,ulong modenum,ref DEVMODE
lpdevmode)Library"kernel32.dll"
//PUBLIC FUNCTION ulong DeviceCapabilities(ref string lpDeviceName,ref string lpPort,ulong
iIndex,ref string lpOutput,ref DEVMODE lpDevMode) LIBRARY "winspool.drv" ALIAS FOR
"DeviceCapabilitiesA"
PUBLIC FUNCTION ulong GetVolumeInformation(string lpRootPathName,ref string lpVolumeNameBuffer,
ulong nVolumeNameSize,ref ulong lpVolumeSerialNumber,ref ulong lpMaximumComponentLength,
ref ulong lpFileSystemFlags,ref string lpFileSystemNameBuffer,ulong nFileSystemNameSize)
LIBRARY "kernel32.dll" ALIAS FOR "GetVolumeInformationA"
FUNCTION long GetMACAddress(long lana,ref long addr[6]) Library "utils.dll"
FUNCTION long GetLanaID(ref long lana[254]) LIBRARY "utils.dll"
Function ulong GetMHZ()Library"mydll.dll"
ulong ul_drivetype
string ls_drive
ul_drivetype = GetDriveType(a_drivename)
choose case ul_drivetype
case 0
ls_Drive = "Unknown Driver"
Case 1
ls_Drive = "Drive Does Not exist"
Case 2
ls_Drive = "Floppy driver"
Case 3
ls_Drive = "HardDisk driver"
Case 4
ls_Drive = "Network driver"
Case 5
ls_Drive = "CD-ROM driver"
Case 6
ls_Drive = "RAM driver"
End choose
Return ls_drive
6)、of_GetIPAddress(),获得本机IP地址。
return ole_1.object.localip
7)、of_GetKeyBoardType(),获得用户键盘种类。
return GetKeyboardType(0)
8)、of_GetLongInID(),获得登陆的用户名称。
string ls_username,ls_cmpname
ulong ll_length,lul_runtime
ls_cmpname = ""
ls_username = space(64)
ll_length = 64
lul_runtime=WNetGetUser(ls_cmpName,ls_UserName,ll_Length)
If lul_runtime=0 then
return ls_UserName
else
return "Error"
End if
9)、of_GetMacAddress(),获得网卡的物理地址。
long lana[254],ll_lananum,mac[6]
long i,j
If Not FileExists("utils.dll") Then
MessageBox("错误","无法找到 utils.dll 文件")
Return ""
End If
j=1
String ls_macaddress[254]
ll_lananum = GetLanaID(lana)
for i=1 to ll_lananum
if GetMacAddress(lana[i],mac) = 0 then
ls_macaddress[j] = string(mac[1])+"," +string(mac[2])+"," + string(mac[3])+"," +
string(mac[4])+"," + string(mac[5])+"," + string(mac[6])
j++
end if
next
string ls_return
For i = 1 to j
If ls_macaddress[i]="" Then exit
ls_return = ls_return+ls_macaddress[i]+"|"
next
return ls_return
IF not Fileexists("Mydll.dll") Then
MessageBox("错误","无法找到 MyDll.dll !!!")
return 0
End If
ulong ul_mhz
ul_mhz = GetMhz()
return ul_mhz
12)、of_GetNetCard(),获得网卡的名称。
environment l_env
getenvironment(l_env)
Integer li_rtn
string ls_username
Choose case l_env.ostype
case Windows!
li_rtn =
RegistryGet("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net\0000","DriverDesc",
RegString!,ls_username)
If li_rtn <> 1 Then
li_rtn =
RegistryGet("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Net\0001","DriverDesc",
RegString!,ls_username)
if li_rtn<> 1 Then
ls_username = "Ether Netword Card can not be detected"
End if
End if
case WindowsNT!
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\
CurrentVersion\NetworkCards\1","Title",RegString!,ls_username)
End choose
return ls_username