获取当前运行(。。。。.exe)程序的路径

     char buf[MAX_PATH];

1. GetModuleFileName(NULL, buf, MAX_PATH);

2. LPTSTR的数据类型是(char *)(const char *);

3. 获取程序的版本信息

CString GetFileVersion(LPCTSTR szFileName)
{
  CString szVer;
 DWORD dwLen = GetFileVersionInfoSize((char*)(const char*)szFileName, 0);
 char * buf = new char[dwLen + 1];
 if(GetFileVersionInfo((LPTSTR)szFileName,0, dwLen, buf))
 {
  VS_FIXEDFILEINFO * lpInfo = NULL;
  try
  {
   VerQueryValue(buf,TEXT("\\"), (void**)&lpInfo, NULL);
   if(lpInfo)
   {
    szVer.Format(("%d.%d.%d.%d"),
     HIWORD(lpInfo->dwFileVersionMS),
     LOWORD(lpInfo->dwFileVersionMS),
     HIWORD(lpInfo->dwFileVersionLS),
     LOWORD(lpInfo->dwFileVersionLS));
   }  
  }
  catch(...){}
 }
 delete [] buf;

 return szVer;
}

4. 从左边截取多少个字符

CString::Left

// example for CString::Left
CString s( _T("abcdef") );
ASSERT( s.Left(2) == _T("ab") );

CString Overview |  Class Members

5

CString::ReverseFind

int ReverseFind( TCHAR ch ) const;

Return Value

The index of the last character in this CString object that matches the requested character; –1 if the character is not found.

// Example for CString::ReverseFind
CString s( "abcabc" );
ASSERT( s.ReverseFind( 'b' ) == 4 );

 

6 获取系统(自定义)语言

 if(GetSystemDefaultLangID() == 0x0804)
 {
  SetThreadLocale(MAKELCID(LANGID_ZH_CN,SORT_DEFAULT));
  m_sysparam.m_nLanguageID=0;
 }

你可能感兴趣的:(获取当前运行(。。。。.exe)程序的路径)