操作注册表?
如何读写修改注册表?怎么判断什么系统? 问题点数:50、回复次数:3Top
1 楼40Star(斯文、大方、有前途)回复于 2002-06-12 09:14:18 得分 0
GetVersion
The GetVersion function returns the current version number of the operating system.
Note This function has been superseded by GetVersionEx. New applications should use GetVersionEx or VerifyVersionInfo.
DWORD GetVersion(VOID);
Parameters
This function has no parameters.
Return Values
If the function succeeds, the return value is a DWORD value that contains the major and minor version numbers of the operating system in the low order word, and information about the operating system platform in the high order word.
For all platforms, the low order word contains the version number of the operating system. The low-order byte of this word specifies the major version number, in hexadecimal notation. The high-order byte specifies the minor version (revision) number, in hexadecimal notation.
To distinguish between operating system platforms, use the high order bit and the low order byte, as shown in the following table:
Platform High-order bit Low-order byte (major version)
Windows NT/2000 0 3, 4, or 5
Windows 95/98 1 4
Win32s with
Windows 3.1 1 3
Windows NT/2000: The remaining bits in the high-order word specify the build number.
Windows 95/98: The remaining bits of the high-order word are reserved.
Remarks
The GetVersionEx function was developed because many existing applications err when examining the packed DWORD value returned by GetVersion, transposing the major and minor version numbers. GetVersionEx forces applications to explicitly examine each element of version information. VerifyVersionInfo eliminates further potential for error by comparing the required system version with the current system version for you.
The following code fragment illustrates how to extract information from the GetVersion return value:
dwVersion = GetVersion();
// Get the Windows version.
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get the build number for Windows NT/Windows 2000 or Win32s.
if (dwVersion < 0x80000000) // Windows NT/2000
dwBuild = (DWORD)(HIWORD(dwVersion));
else if (dwWindowsMajorVersion < 4) // Win32s
dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
else // Windows 95/98 -- No build number
dwBuild = 0;
Top
2 楼40Star(斯文、大方、有前途)回复于 2002-06-12 09:16:57 得分 50
看看TRegistry
//写入注册表--启动系统时再现
AnsiString S;
TRegistry *Registry = new TRegistry;
Registry->RootKey = HKEY_LOCAL_MACHINE;
// 如果此键不存在则自动创建
Registry->OpenKey("\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);
S = Registry->ReadString("40Star");
if (S!=Application->ExeName)
{
Registry->WriteString("40Star",Application->ExeName);
Registry->CloseKey();
}
delete Registry;Top
3 楼Libran()回复于 2002-06-12 09:33:15 得分 0
读写注册表用TRegistry类,看看帮助
要注意的是使用TRegistry类需包含头文件:
#include <Registry.hpp>Top
4 楼sluizin(冰封箭)回复于 2002-06-12 09:40:01 得分 0
同意楼上。Top
5 楼Libran()回复于 2002-06-12 09:58:38 得分 0
读写注册表用TRegistry类
要注意的是使用TRegistry类需包含头文件
#include <Registry.hpp>Top




