Created
December 15, 2019 09:12
-
-
Save lekoOwO/913cc272a9eeba2abaac684194816a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UNICODE | |
#include <string> | |
#include <windows.h> | |
std::wstring exeDirPath() { | |
wchar_t buffer[MAX_PATH]; | |
GetModuleFileNameW( NULL, buffer, MAX_PATH ); | |
std::wstring::size_type pos = std::wstring( buffer ).find_last_of( L"\\/" ); | |
return std::wstring( buffer ).substr(0, pos); | |
} | |
int wmain(int argc, wchar_t *argv[]){ | |
std::wstring url(argv[1]); | |
std::wstring p32 = L"potplayer32://"; | |
url.replace(0, p32.size(), L"potplayer://"); | |
std::wstring potplayerPath = exeDirPath() + L"\\PotPlayerMini.exe"; | |
LPCWSTR process = potplayerPath.c_str(); | |
std::wstring arg = potplayerPath + L" \"" + url + L"\""; | |
LPWSTR args = &arg[0]; | |
STARTUPINFOW si; | |
PROCESS_INFORMATION pi; | |
ZeroMemory( &si, sizeof(si)); | |
si.cb = sizeof(si); | |
ZeroMemory( &pi, sizeof(pi)); | |
CreateProcessW(process, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment