Skip to content

Instantly share code, notes, and snippets.

@lekoOwO
Created December 15, 2019 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lekoOwO/913cc272a9eeba2abaac684194816a92 to your computer and use it in GitHub Desktop.
Save lekoOwO/913cc272a9eeba2abaac684194816a92 to your computer and use it in GitHub Desktop.
#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