2024-06-13 11:18:25 +08:00
|
|
|
#pragma once
|
|
|
|
#include "YYCCInternal.hpp"
|
|
|
|
#if YYCC_OS == YYCC_OS_WINDOWS
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "WinImportPrefix.hpp"
|
|
|
|
#include <Windows.h>
|
|
|
|
#include "WinImportSuffix.hpp"
|
|
|
|
|
2024-06-14 11:59:08 +08:00
|
|
|
/**
|
|
|
|
* @brief The helper providing assistance to Win32 functions.
|
|
|
|
* @details
|
|
|
|
* This helper is Windows specific.
|
2024-06-18 16:03:41 +08:00
|
|
|
* If current environment is not Windows, the whole namespace will be unavailable.
|
2024-06-14 11:59:08 +08:00
|
|
|
*/
|
2024-06-13 11:18:25 +08:00
|
|
|
namespace YYCC::WinFctHelper {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get Windows used HANDLE for current module.
|
|
|
|
* @details
|
|
|
|
* If your target is EXE, the current module simply is your program self.
|
|
|
|
* However, if your target is DLL, the current module is your DLL, not the EXE loading your DLL.
|
2024-06-14 11:59:08 +08:00
|
|
|
*
|
2024-06-13 11:18:25 +08:00
|
|
|
* This function is frequently used by DLL.
|
|
|
|
* Because some design need the HANDLE of current module, not the host EXE loading your DLL.
|
|
|
|
* For example, you may want to get the name of your built DLL at runtime, then you should pass current module HANDLE, not the HANDLE of EXE.
|
|
|
|
* Or, if you want to get the path to your DLL, you also should pass current module HANDLE.
|
|
|
|
* @return A Windows HANDLE pointing to current module, NULL if failed.
|
|
|
|
*/
|
|
|
|
HMODULE GetCurrentModule();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get path to Windows temp folder.
|
2024-06-15 16:44:11 +08:00
|
|
|
* @param[out] ret
|
|
|
|
* The variable receiving UTF8 encoded path to Windows temp folder.
|
|
|
|
* @return True if success, otherwise false.
|
2024-06-13 11:18:25 +08:00
|
|
|
*/
|
2024-06-15 16:44:11 +08:00
|
|
|
bool GetTempDirectory(std::string& ret);
|
2024-06-13 11:18:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the file name of given module HANDLE
|
2024-06-14 11:59:08 +08:00
|
|
|
* @param[in] hModule
|
2024-06-13 11:18:25 +08:00
|
|
|
* The HANDLE to the module where we want get file name.
|
2024-06-14 11:59:08 +08:00
|
|
|
* It is same as the HANDLE parameter of \c GetModuleFileName.
|
2024-06-15 16:44:11 +08:00
|
|
|
* @param[out] ret
|
|
|
|
* The variable receiving UTF8 encoded file name of given module.
|
|
|
|
* @return True if success, otherwise false.
|
2024-06-13 11:18:25 +08:00
|
|
|
*/
|
2024-06-15 16:59:54 +08:00
|
|
|
bool GetModuleFileName(HINSTANCE hModule, std::string& ret);
|
2024-06-17 12:46:32 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the path to LOCALAPPDATA.
|
|
|
|
* @details LOCALAPPDATA usually was used as putting local app data files
|
|
|
|
* @param[out] ret
|
|
|
|
* The variable receiving UTF8 encoded path to LOCALAPPDATA.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
bool GetLocalAppData(std::string& ret);
|
|
|
|
|
2024-06-13 11:18:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|