コード例 #1
0
ファイル: DLL.cpp プロジェクト: ArchangelSDY/Qt7z
bool MyGetModuleFileName(FString &path)
{
  HMODULE hModule = g_hInstance;
  path.Empty();
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    TCHAR s[MAX_PATH + 2];
    s[0] = 0;
    DWORD size = ::GetModuleFileName(hModule, s, MAX_PATH + 1);
    if (size <= MAX_PATH && size != 0)
    {
      path = fas2fs(s);
      return true;
    }
  }
  else
  #endif
  {
    WCHAR s[MAX_PATH + 2];
    s[0] = 0;
    DWORD size = ::GetModuleFileNameW(hModule, s, MAX_PATH + 1);
    if (size <= MAX_PATH && size != 0)
    {
      path = us2fs(s);
      return true;
    }
  }
  return false;
}
コード例 #2
0
ファイル: FileDir.cpp プロジェクト: BenjaminSiskoo/mame
bool MyGetFullPathName(CFSTR fileName, FString &resFullPath)
{
  resFullPath.Empty();
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    TCHAR s[MAX_PATH + 2];
    s[0] = 0;
    LPTSTR fileNamePointer = 0;
    DWORD needLength = ::GetFullPathName(fs2fas(fileName), MAX_PATH + 1, s, &fileNamePointer);
    if (needLength == 0 || needLength > MAX_PATH)
      return false;
    resFullPath = fas2fs(s);
    return true;
  }
  else
  #endif
  {
    LPWSTR fileNamePointer = 0;
    WCHAR s[MAX_PATH + 2];
    s[0] = 0;
    DWORD needLength = ::GetFullPathNameW(fs2us(fileName), MAX_PATH + 1, s, &fileNamePointer);
    if (needLength == 0)
      return false;
    if (needLength <= MAX_PATH)
    {
      resFullPath = us2fs(s);
      return true;
    }
    #ifdef WIN_LONG_PATH
    needLength++;
    UString temp;
    LPWSTR buffer = temp.GetBuffer(needLength + 1);
    buffer[0] = 0;
    DWORD needLength2 = ::GetFullPathNameW(fs2us(fileName), needLength, buffer, &fileNamePointer);
    temp.ReleaseBuffer();
    if (needLength2 > 0 && needLength2 <= needLength)
    {
      resFullPath = us2fs(temp);
      AddTrailingDots(fileName, resFullPath);
      return true;
    }
    #endif
    return false;
  }
}
コード例 #3
0
ファイル: FileDir.cpp プロジェクト: BenjaminSiskoo/mame
bool MyGetTempPath(FString &path)
{
  path.Empty();
  DWORD needLength;
  #ifndef _UNICODE
  if (!g_IsNT)
  {
    TCHAR s[MAX_PATH + 2];
    s[0] = 0;
    needLength = ::GetTempPath(MAX_PATH + 1, s);
    path = fas2fs(s);
  }
  else
  #endif
  {
    WCHAR s[MAX_PATH + 2];
    s[0] = 0;
    needLength = ::GetTempPathW(MAX_PATH + 1, s);;
    path = us2fs(s);
  }
  return (needLength > 0 && needLength <= MAX_PATH);
}