擷取系統版本AND建立快捷方式 擷取系統版本: DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
dwVersion = GetVersion(); // Get the Windows version.
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); // low-order word contains the version number of the operating system
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); //high-order byte specifies the minor version (revision) number, in hexadecimal notation
if (dwVersion < 0x80000000) {
dwBuild = (DWORD)(HIWORD(dwVersion)); }
CString D_version;
D_version.Format("V=%d,D=%d,S=%d",dwMajorVersion, dwMinorVersion, dwBuild);
AfxMessageBox(D_version);
·········------------------------------------------
Operating system | Version number |
---|---|
Windows 7 | 6.1 |
Windows Server 2008 R2 | 6.1 |
Windows Server 2008 | 6.0 |
Windows Vista | 6.0 |
Windows Server 2003 R2 | 5.2 |
Windows Server 2003 | 5.2 |
Windows XP | 5.1 |
Windows 2000 | 5.0 |
------------------------------------------------------------------------------------------ 建立快捷方式主要的: // 取得開始菜單或桌面的PIDL LPITEMIDLIST pidlBeginAt; SHGetSpecialFolderLocation(HWND_DESKTOP,CSIDL_COMMON_PROGRAMS,&pidlBeginAt) ; // 把PIDL轉換為路徑名
char szLinkPath[MAX_PATH];
SHGetPathFromIDList(pidlBeginAt,szLinkPath);
szLink = szLinkPath; //CreateDirectory(szLink,NULL); //建立快捷方式目錄 CreateLink(LPCSTR path, LPCSTR pszLink)
{
HRESULT hres;
IShellLink *psl;
CoInitialize (NULL); // Create an IShellLink object and get a pointer to the IShellLink
// interface (returned from CoCreateInstance).
hres = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)&psl);
if (SUCCEEDED (hres))
{
IPersistFile *ppf; // Query IShellLink for the IPersistFile interface for
// saving the shortcut in persistent storage.
hres = psl->QueryInterface (IID_IPersistFile, (void **)&ppf);
if (SUCCEEDED (hres))
{
WORD wsz [MAX_PATH]; // buffer for Unicode string // Set the path to the shortcut target.
hres = psl->SetPath (path); if (! SUCCEEDED (hres))
return false; // Set the description of the shortcut. CSting pszDesc;
//hres = psl->SetDescription (pszDesc); if (! SUCCEEDED (hres))
return false; // Ensure that the string consists of ANSI characters.
MultiByteToWideChar (CP_ACP, 0, pszLink, -1, wsz, MAX_PATH); // Save the shortcut via the IPersistFile::Save member function.
hres = ppf->Save (wsz, TRUE); if (! SUCCEEDED (hres))
return false;
// Release the pointer to IPersistFile.
ppf->Release ();
}
// Release the pointer to IShellLink.
psl->Release ();
}
CoUninitialize ();
return true; }