Skip to content

Instantly share code, notes, and snippets.

@oakaigh
Last active October 21, 2018 09:51
Show Gist options
  • Save oakaigh/91b02ebb3c9e22753b6ca95002a228a4 to your computer and use it in GitHub Desktop.
Save oakaigh/91b02ebb3c9e22753b6ca95002a228a4 to your computer and use it in GitHub Desktop.
BOOL IsUserInteractive()
{
BOOL bIsUserInteractive = TRUE;
HWINSTA hWinStation = GetProcessWindowStation();
if (hWinStation != NULL)
{
USEROBJECTFLAGS uof = {0};
if (GetUserObjectInformation(hWinStation, UOI_FLAGS, &uof, sizeof(USEROBJECTFLAGS), NULL) && ((uof.dwFlags & WSF_VISIBLE) == 0))
bIsUserInteractive = FALSE;
}
return bIsUserInteractive;
}
  char charArray[MAX_PATH];
  HMODULE hmodule = GetModuleHandle(0);
  GetModuleFileName(hmodule, charArray, MAX_PATH);
  CopyFile(charArray, argv[1], TRUE);