Southsoftware.com
.:Pricing
Home
Products
Downloads
Support
Contacts
Site Map
.:RunAsUser DLL
About product
Download trial
Purchase license
View screenshot
Online manual
FAQ & Support
.:Follow us
Follow us on Facebook Follow us on Twitter Follow us on YouTube
   

Callback functions

Include file: runasuser.h

RunAsUser_StateFn
SUMMARY:
Callback function for RunAsUser_CreateProcess().
ARGUMENTS:
state - state (RUNASSTATE_ constants);
dwError - error code;
pszErrorText - debug information;
lParam - user-defined argument (lParam from RunAsUser_CreateProcess()).
DECLARATION:
typedef VOID (CALLBACK * RunAsUser_StateFn)(RUNASSTATE state, DWORD dwError, LPCTSTR pszErrorText, LPARAM lParam);
REMARKS:
This example shows how to use RunAsUser_State function to write extended log to a file:
VOID CALLBACK RunAsUserState(RUNASSTATE state, DWORD dwError,
  LPCTSTR pszErrorText, LPARAM lParam)
{
  HANDLE hLogFile;
  DWORD dwWritten;
  TCHAR szLogText[256];
  hLogFile = CreateFile(szLogFile,
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ, NULL, OPEN_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, NULL);
  if (hLogFile != INVALID_HANDLE_VALUE)
  {
    SetFilePointer(hLogFile, 0, 0, FILE_END);
    _sntprintf(szLogText, sizeof(szLogText)/sizeof(TCHAR),
    _T("state = %u\r\ndwError = %u\r\npszErrorLog:\r\n"),
    state, dwError);
    WriteFile(hLogFile, szLogText,
    _tcslen(szLogText)*sizeof(TCHAR), &dwWritten, NULL);
    WriteFile(hLogFile, pszErrorText,
    _tcslen(pszErrorText)*sizeof(TCHAR), &dwWritten, NULL);
    CloseHandle(hLogFile);
  }
}

RunAsUser_WaitFn
SUMMARY:
Callback function for RunAsUser_CreateProcess().
ARGUMENTS:
hProcess - handle to the started process;
dwProcessId - process identifier (PID) of the started process;
lParam - user-defined argument (lParam from RunAsUser_CreateProcess()).
DECLARATION:
typedef VOID (CALLBACK * RunAsUser_WaitFn)(HANDLE hProcess, DWORD dwProcessId, LPARAM lParam);
REMARKS:
The hProcess has full access to the started process.

This example shows how to terminate the process after it is running for 10 seconds:
VOID CALLBACK RunAsUserWait(HANDLE hProcess,
  DWORD dwProcessId, LPARAM lParam)
{
  if (WaitForSingleObject(hProcess, 10000)==WAIT_TIMEOUT)
  {
    DWORD dwPrivDebug = SE_PRIVILEGE_USED_FOR_ACCESS;
    if (RunAsUser_AdjustPrivilege(SE_DEBUG_NAME,
      SE_PRIVILEGE_ENABLED, &dwPrivDebug))
    {
      TerminateProcess(hProcess, 0);
      RunAsUser_AdjustPrivilege(SE_DEBUG_NAME,
        dwPrivDebug, NULL);
    }
  }
}

Back to contents

   
About us   Privacy policy   Terms of use   Link to us
Current Version: 1.08
Buy RunAsUser DLL now for only $ 199.95 USD. We accept variety of payment options: Credit Cards, Checks, Wire Transfers, PayPal. Payments can be made Online, by PO, Fax, Mail or Phone.
.:Requirements
Computer: Minimum required by operating system you are running.
Disk Space: Under 4 MB
Operating System: RunAsUser DLL requires a Microsoft Windows NT 4.0 / 2000 / XP / Server 2003 / Server 2008 / Vista / 7 / Server 2012 / 8 Desktop 32 or 64-bit operating system.