获取系统版本AND创建快捷方式

获取系统版本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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值