Compare commits
8 Commits
1ab7fd1129
...
1.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| eec9e25e12 | |||
| 3b4853acda | |||
| cea13986f0 | |||
| 3641ffdad9 | |||
| 7fa68792fb | |||
| ebdd35b1e1 | |||
| b986bfde39 | |||
| ecfb2f206d |
@@ -1,7 +1,35 @@
|
||||
#include "ApplicationData.h"
|
||||
#include "Util.h"
|
||||
#include "AudioApi.h"
|
||||
#include <functiondiscoverykeys.h>
|
||||
|
||||
AudioDevice::AudioDevice()
|
||||
AudioDevice::AudioDevice(IMMDevice* device, LPCWSTR deviceId)
|
||||
{
|
||||
id = std::wstring(deviceId);
|
||||
|
||||
IPropertyStore* propertyStore;
|
||||
HRESULT err = device->OpenPropertyStore(STGM_READ, &propertyStore);
|
||||
isError(err, "Failed to open prop store: ");
|
||||
|
||||
PROPVARIANT deviceNameProp;
|
||||
const wchar_t* deviceName;
|
||||
err = getDevicePropertyString(propertyStore, PKEY_Device_FriendlyName, &deviceNameProp, deviceName);
|
||||
isError(err, "Failed to read name of device :");
|
||||
name = utf8Encode(deviceName);
|
||||
|
||||
err = device->GetState(&state);
|
||||
isError(err, "Failed to reat state of device: ");
|
||||
|
||||
err = device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&volumeInterface);
|
||||
isError(err, "Failed to get audio endpoint volume interface: ");
|
||||
|
||||
err = device->Activate(__uuidof(IAudioMeterInformation), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&meterInterface);
|
||||
isError(err, "Failed to get audio meter interface: ");
|
||||
|
||||
if (propertyStore)
|
||||
{
|
||||
propertyStore->Release();
|
||||
}
|
||||
}
|
||||
|
||||
AudioDevice::AudioDevice(AudioDevice&& other) noexcept
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
bool isDefaultMedia = {};
|
||||
bool isDefaultCommunication = {};
|
||||
|
||||
AudioDevice();
|
||||
AudioDevice(IMMDevice* device, LPCWSTR deviceId);
|
||||
AudioDevice(AudioDevice&& other) noexcept;
|
||||
AudioDevice& operator=(AudioDevice&& other) noexcept;
|
||||
~AudioDevice();
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
#include "resource.h"
|
||||
#include "AsuroTool.h"
|
||||
|
||||
class __declspec(uuid("3bc52579-15fd-43bb-9686-6273c238535e")) TrayGUID;
|
||||
|
||||
UINT const WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
||||
UINT const WMAPP_HIDEFLYOUT = WM_APP + 2;
|
||||
const size_t MAX_FONT_PATH_LENGTH = 2048;
|
||||
const UINT TRAY_ID = 420;
|
||||
const UINT WMAPP_NOTIFYCALLBACK = WM_APP + 1;
|
||||
|
||||
// Globals for use in callbacks
|
||||
DrawData* gDrawData;
|
||||
@@ -36,6 +35,13 @@ bool isHidden = false;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::wstring appDir;
|
||||
getAppDir(appDir);
|
||||
if (_wchdir(appDir.c_str()) != 0)
|
||||
{
|
||||
std::cout << "Failed to set working dir." << std::endl;
|
||||
}
|
||||
|
||||
ApplicationData applicationData{};
|
||||
ImGuiCallbacks callbacks{};
|
||||
|
||||
@@ -48,20 +54,30 @@ int main()
|
||||
|
||||
void init(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
std::wstring appPath;
|
||||
getAppDir(appPath);
|
||||
char appPathStr[MAX_FONT_PATH_LENGTH];
|
||||
HRESULT convResult = WideCharToMultiByte(CP_UTF8, NULL, &appPath[0], -1, appPathStr, MAX_FONT_PATH_LENGTH, NULL, nullptr);
|
||||
isError(convResult, "Failed to convert path: ");
|
||||
|
||||
// sad :(
|
||||
gDrawData = &drawData;
|
||||
gAppData = &appData;
|
||||
|
||||
// Load text font
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->AddFontFromFileTTF("Montserrat-Regular.ttf", 18.0f);
|
||||
std::string fontPath = std::string(appPathStr);
|
||||
fontPath.append("\\Montserrat-Regular.ttf");
|
||||
io.Fonts->AddFontFromFileTTF(fontPath.c_str(), 18.0f);
|
||||
|
||||
// Load icon font
|
||||
static const ImWchar icons_ranges[] = { 0xEA01, 0xF2DF, 0 };
|
||||
ImFontConfig icons_config;
|
||||
icons_config.MergeMode = true;
|
||||
icons_config.PixelSnapH = true;
|
||||
io.Fonts->AddFontFromFileTTF("remixicon.ttf", 14.0f, &icons_config, icons_ranges);
|
||||
std::string iconFontPath = std::string(appPathStr);
|
||||
iconFontPath.append("\\remixicon.ttf");
|
||||
io.Fonts->AddFontFromFileTTF(iconFontPath.c_str(), 14.0f, &icons_config, icons_ranges);
|
||||
|
||||
// Set window icon
|
||||
HINSTANCE instance = GetModuleHandle(NULL);
|
||||
@@ -75,8 +91,8 @@ void init(DrawData& drawData, ApplicationData& appData)
|
||||
// Set tray icon
|
||||
NOTIFYICONDATA nid = { sizeof(nid) };
|
||||
nid.hWnd = drawData.window_handle;
|
||||
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_SHOWTIP | NIF_GUID;
|
||||
nid.guidItem = __uuidof(TrayGUID);
|
||||
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_SHOWTIP;
|
||||
nid.uID = TRAY_ID;
|
||||
nid.uCallbackMessage = WMAPP_NOTIFYCALLBACK;
|
||||
|
||||
HRESULT iconResult;
|
||||
@@ -123,10 +139,6 @@ void draw(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
justDocked = false;
|
||||
|
||||
// sad :(
|
||||
gDrawData = &drawData;
|
||||
gAppData = &appData;
|
||||
|
||||
// Actual Drawing
|
||||
if (isHidden)
|
||||
{
|
||||
@@ -167,9 +179,9 @@ void cleanup(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
// Remove tray icon
|
||||
NOTIFYICONDATA nid = { sizeof(nid) };
|
||||
nid.uFlags = NIF_GUID;
|
||||
nid.guidItem = __uuidof(TrayGUID);
|
||||
bool test = Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
nid.hWnd = drawData.window_handle;
|
||||
nid.uID = TRAY_ID;
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
}
|
||||
|
||||
ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
||||
@@ -181,9 +193,7 @@ ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
if (ImGui::BeginMenu("Settings"))
|
||||
{
|
||||
bool prevDocked = appData.settings.docked;
|
||||
ImGui::Checkbox("Docked", &appData.settings.docked);
|
||||
if (appData.settings.docked != prevDocked)
|
||||
if (ImGui::Checkbox("Docked", &appData.settings.docked))
|
||||
{
|
||||
closeMenu = true;
|
||||
updateDocked(drawData, appData);
|
||||
@@ -378,12 +388,13 @@ LRESULT CALLBACK trayIconEventHandler(int code, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (data->message == WMAPP_NOTIFYCALLBACK)
|
||||
{
|
||||
switch (data->lParam)
|
||||
auto id = HIWORD(data->lParam);
|
||||
auto trayEvent = LOWORD(data->lParam);
|
||||
|
||||
if (id == TRAY_ID && trayEvent == WM_LBUTTONUP)
|
||||
{
|
||||
case NIN_SELECT:
|
||||
glfwShowWindow(gDrawData->window);
|
||||
glfwRestoreWindow(gDrawData->window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,45 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
|
||||
IDI_ICON1 ICON "kaiju.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,3,1
|
||||
PRODUCTVERSION 1,0,3,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "200004b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Asuro"
|
||||
VALUE "FileDescription", "Audio Thingy"
|
||||
VALUE "FileVersion", "1.0.3.1"
|
||||
VALUE "InternalName", "AsuroTool.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2022"
|
||||
VALUE "OriginalFilename", "AsuroTool.exe"
|
||||
VALUE "ProductName", "Audio Thingy"
|
||||
VALUE "ProductVersion", "1.0.3.1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x2000, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
|
||||
@@ -97,6 +97,9 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -114,6 +117,9 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -127,6 +133,9 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -144,6 +153,9 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -31,7 +31,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
||||
deviceList.clear();
|
||||
|
||||
HRESULT err;
|
||||
IMMDeviceCollection* deviceCollection = NULL;
|
||||
IMMDeviceCollection* deviceCollection = nullptr;
|
||||
|
||||
err = audioData.deviceEnumerator->EnumAudioEndpoints(deviceType, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED, &deviceCollection);
|
||||
if (isError(err, "Failed to enumerate audio devices: ")) return;
|
||||
@@ -40,7 +40,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
||||
err = deviceCollection->GetCount(&deviceCount);
|
||||
if (isError(err, "Failed to count audio devices: ")) return;
|
||||
|
||||
IMMDevice* defaultConsoleDevice = NULL;
|
||||
IMMDevice* defaultConsoleDevice = nullptr;
|
||||
LPWSTR defaultConsoleId = nullptr;
|
||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eConsole, &defaultConsoleDevice);
|
||||
if (!FAILED(err))
|
||||
@@ -48,7 +48,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
||||
defaultConsoleDevice->GetId(&defaultConsoleId);
|
||||
}
|
||||
|
||||
IMMDevice* defaultMediaOutput = NULL;
|
||||
IMMDevice* defaultMediaOutput = nullptr;
|
||||
LPWSTR defaultMediaId = nullptr;
|
||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eMultimedia, &defaultMediaOutput);
|
||||
if (!FAILED(err))
|
||||
@@ -56,7 +56,7 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
||||
defaultMediaOutput->GetId(&defaultMediaId);
|
||||
}
|
||||
|
||||
IMMDevice* defaultCommunicationOutput = NULL;
|
||||
IMMDevice* defaultCommunicationOutput = nullptr;
|
||||
LPWSTR defaultCommunicationId = nullptr;
|
||||
err = audioData.deviceEnumerator->GetDefaultAudioEndpoint(deviceType, ERole::eCommunications, &defaultCommunicationOutput);
|
||||
if (!FAILED(err))
|
||||
@@ -66,57 +66,35 @@ void loadAudioDevices(AudioData& audioData, std::vector<AudioDevice>& deviceList
|
||||
|
||||
for (UINT i = 0; i < deviceCount; i += 1)
|
||||
{
|
||||
AudioDevice deviceData{};
|
||||
|
||||
err = deviceCollection->Item(i, &deviceData.device);
|
||||
IMMDevice* device;
|
||||
err = deviceCollection->Item(i, &device);
|
||||
if (isError(err, std::stringstream("Failed to get device ") << i << ": "))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
LPWSTR deviceId;
|
||||
err = deviceData.device->GetId(&deviceId);
|
||||
isError(err, std::stringstream("Failed to get device id ") << i << ": ");
|
||||
deviceData.id = std::wstring(deviceId);
|
||||
|
||||
IPropertyStore* propertyStore;
|
||||
err = deviceData.device->OpenPropertyStore(STGM_READ, &propertyStore);
|
||||
isError(err, std::stringstream("Failed to open device ") << i << "prop store: ");
|
||||
|
||||
PROPVARIANT deviceNameProp;
|
||||
const wchar_t* deviceName;
|
||||
err = getDevicePropertyString(propertyStore, PKEY_Device_FriendlyName, &deviceNameProp, deviceName);
|
||||
isError(err, std::stringstream("Failed to read name of device ") << i << ": ");
|
||||
deviceData.name = utf8Encode(deviceName);
|
||||
|
||||
err = deviceData.device->GetState(&deviceData.state);
|
||||
isError(err, std::stringstream("Failed to reat state of device ") << i << ": ");
|
||||
|
||||
err = deviceData.device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&deviceData.volumeInterface);
|
||||
isError(err, "Failed to get audio endpoint volume interface: ");
|
||||
|
||||
err = deviceData.device->Activate(__uuidof(IAudioMeterInformation), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&deviceData.meterInterface);
|
||||
isError(err, "Failed to get audio meter interface: ");
|
||||
err = device->GetId(&deviceId);
|
||||
if (!isError(err, std::stringstream("Failed to get device id ") << i << ": "))
|
||||
{
|
||||
AudioDevice audioDevice(device, deviceId);
|
||||
|
||||
if (defaultConsoleId)
|
||||
{
|
||||
deviceData.isDefaultConsole = wcscmp(defaultConsoleId, deviceId) == 0;
|
||||
audioDevice.isDefaultConsole = wcscmp(defaultConsoleId, deviceId) == 0;
|
||||
}
|
||||
if (defaultMediaId)
|
||||
{
|
||||
deviceData.isDefaultMedia = wcscmp(defaultMediaId, deviceId) == 0;
|
||||
audioDevice.isDefaultMedia = wcscmp(defaultMediaId, deviceId) == 0;
|
||||
}
|
||||
if (defaultCommunicationId)
|
||||
{
|
||||
deviceData.isDefaultCommunication = wcscmp(defaultCommunicationId, deviceId) == 0;
|
||||
audioDevice.isDefaultCommunication = wcscmp(defaultCommunicationId, deviceId) == 0;
|
||||
}
|
||||
|
||||
deviceList.push_back(std::move(deviceData));
|
||||
|
||||
if (propertyStore)
|
||||
{
|
||||
propertyStore->Release();
|
||||
deviceList.push_back(std::move(audioDevice));
|
||||
}
|
||||
|
||||
CoTaskMemFree(deviceId);
|
||||
}
|
||||
|
||||
@@ -150,7 +128,7 @@ HRESULT getDevicePropertyString(IPropertyStore* propertyStore, const PROPERTYKEY
|
||||
|
||||
void setDefaultAudioDevice(AudioData& audioData, const wchar_t* deviceId, ERole role)
|
||||
{
|
||||
IPolicyConfigVista* pPolicyConfig;
|
||||
IPolicyConfigVista* pPolicyConfig = nullptr;
|
||||
|
||||
HRESULT hr = CoCreateInstance(__uuidof(CPolicyConfigVistaClient), NULL, CLSCTX_ALL, __uuidof(IPolicyConfigVista), (LPVOID*)&pPolicyConfig);
|
||||
if (!isError(hr, "Failed to set default audio device: "))
|
||||
|
||||
@@ -34,7 +34,25 @@ HRESULT __stdcall AudioNotificationListener::OnDeviceAdded(LPCWSTR pwstrDeviceId
|
||||
HRESULT result = audioData->deviceEnumerator->GetDevice(pwstrDeviceId, &newDevice);
|
||||
if (SUCCEEDED(result) && newDevice != nullptr)
|
||||
{
|
||||
// TODO: add to device list
|
||||
IMMEndpoint* endpoint;
|
||||
result = newDevice->QueryInterface(&endpoint);
|
||||
if (SUCCEEDED(result) && endpoint != nullptr)
|
||||
{
|
||||
EDataFlow dataFlow;
|
||||
result = endpoint->GetDataFlow(&dataFlow);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
AudioDevice audioDevice(newDevice, pwstrDeviceId);
|
||||
if (dataFlow == EDataFlow::eCapture)
|
||||
{
|
||||
audioData->recordingDevices.push_back(std::move(audioDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
audioData->playbackDevices.push_back(std::move(audioDevice));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -50,7 +68,9 @@ HRESULT __stdcall AudioNotificationListener::OnDeviceRemoved(LPCWSTR pwstrDevice
|
||||
if (wcscmp(deviceListIterator->id.c_str(), pwstrDeviceId) == 0)
|
||||
{
|
||||
deviceListIterator = deviceList.erase(deviceListIterator);
|
||||
continue;
|
||||
}
|
||||
deviceListIterator++;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,7 +146,7 @@ HRESULT __stdcall AudioNotificationListener::QueryInterface(REFIID riid, void**
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppvObject = NULL;
|
||||
*ppvObject = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,19 +74,16 @@ void setAutostart(bool newValue)
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
HKEY runKey = NULL;
|
||||
HKEY runKey = nullptr;
|
||||
hr = RegCreateKey(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &runKey);
|
||||
if (isError(hr, "Failed to find/create autostart run key: ")) return;
|
||||
|
||||
if (newValue)
|
||||
{
|
||||
std::wstring appPath;
|
||||
appPath.resize(MAX_PATH_LENGTH);
|
||||
hr = GetModuleFileName(NULL, &appPath[0], static_cast<DWORD>(appPath.size()));
|
||||
if (isError(hr, "Failed to get executable name: ")) return;
|
||||
appPath.resize(wcslen(appPath.data()));
|
||||
if (FAILED(getAppPath(appPath))) return;
|
||||
|
||||
hr = RegSetValueEx(runKey, KEY_APP_NAME, 0, REG_SZ, (BYTE*)appPath.c_str(), (appPath.size() + 1) * sizeof(wchar_t));
|
||||
hr = RegSetValueEx(runKey, KEY_APP_NAME, 0, REG_SZ, (BYTE*)appPath.c_str(), static_cast<DWORD>((appPath.size() + 1) * sizeof(wchar_t)));
|
||||
if (isError(hr, "Failed to write autostart key: ")) return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "Util.h"
|
||||
#include "pathcch.h"
|
||||
|
||||
bool isError(const HRESULT result, const std::stringstream message)
|
||||
{
|
||||
@@ -29,3 +30,24 @@ std::string utf8Encode(const std::wstring& wstr)
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &resultString[0], sizeNeeded, NULL, NULL);
|
||||
return resultString;
|
||||
}
|
||||
|
||||
HRESULT getAppPath(std::wstring& outPath)
|
||||
{
|
||||
const size_t MAX_PATH_LENGTH = 32767;
|
||||
outPath.resize(MAX_PATH_LENGTH);
|
||||
HRESULT hr = GetModuleFileName(NULL, &outPath[0], static_cast<DWORD>(outPath.size()));
|
||||
if (isError(hr, "Failed to get executable name: ")) return hr;
|
||||
outPath.resize(wcslen(outPath.data()));
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT getAppDir(std::wstring& outPath)
|
||||
{
|
||||
HRESULT hr = getAppPath(outPath);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = PathCchRemoveFileSpec(&outPath[0], static_cast<DWORD>(outPath.size()));
|
||||
if (isError(hr, "Failed to get executable dir: ")) return hr;
|
||||
outPath.resize(wcslen(outPath.data()));
|
||||
return hr;
|
||||
}
|
||||
@@ -6,3 +6,5 @@
|
||||
bool isError(const HRESULT result, const std::stringstream message);
|
||||
bool isError(const HRESULT result, const char* message);
|
||||
std::string utf8Encode(const std::wstring& wstr);
|
||||
HRESULT getAppPath(std::wstring& outPath);
|
||||
HRESULT getAppDir(std::wstring& outPath);
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>E:\Code\glfw-3.3.7.bin.WIN64\lib-vc2022;D:\Applications\VulkanSDK\1.2.182.0\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -130,6 +132,8 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>E:\Code\glfw-3.3.7.bin.WIN64\lib-vc2022;D:\Applications\VulkanSDK\1.2.182.0\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -149,6 +153,8 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>E:\Code\glfw-3.3.7.bin.WIN64\lib-vc2022;D:\Applications\VulkanSDK\1.2.182.0\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -172,6 +178,8 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>E:\Code\glfw-3.3.7.bin.WIN64\lib-vc2022;D:\Applications\VulkanSDK\1.2.182.0\Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -96,6 +96,8 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -112,6 +114,8 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -124,6 +128,8 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -140,6 +146,8 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user