Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. CoInitializeEx(NULL, COINIT_MULTITHREADED);
  2. LPCWSTR appId = L"Microsoft.Windows.Photos_8wekyb3d8bbwe!App";
  3. LPCWSTR imageArg = L" C:\data\Users\Public\Pictures\image123.png";
  4. IApplicationActivationManager* paam = NULL;
  5. HRESULT hr = E_FAIL;
  6.  
  7. __try
  8. {
  9. hr = CoCreateInstance(CLSID_ApplicationActivationManager, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&paam));
  10. if (FAILED(hr))
  11. {
  12. cout << "Error creating CoCreateINstance & HR is" <<hr<< endl;
  13. return 0;
  14. }
  15.  
  16. DWORD pid = 0;
  17. hr = paam->ActivateApplication(appId, imageArg, AO_NONE, &pid);
  18. if (FAILED(hr))
  19. {
  20. cout << "Error in ActivateApplication call & HR is " <<hr<< endl;
  21. return 0;
  22. }
  23.  
  24. cout << hex << hr;
  25. if (hr == 0)
  26. wprintf(L"Activated %s with pid %drn", appId, pid);
  27. }
  28. __finally
  29. {
  30. if (paam) paam->Release();
  31. }
  32.  
  33. CoUninitialize();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement