Click here to Skip to main content
15,889,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Difference of Floating Point Optimization in Fortran & C++ Pin
Ted Ferenc30-Dec-03 21:53
Ted Ferenc30-Dec-03 21:53 
GeneralRe: Difference of Floating Point Optimization in Fortran & C++ Pin
markkuk30-Dec-03 22:59
markkuk30-Dec-03 22:59 
GeneralMFC with 2 views using Doc/View style Pin
R. Thomas30-Dec-03 20:58
R. Thomas30-Dec-03 20:58 
GeneralRe: MFC with 2 views using Doc/View style Pin
Monty230-Dec-03 21:17
Monty230-Dec-03 21:17 
GeneralRe: MFC with 2 views using Doc/View style Pin
R. Thomas1-Jan-04 15:56
R. Thomas1-Jan-04 15:56 
GeneralQuery in Microsoft Installshield for VC++ Pin
bhargav_ram30-Dec-03 20:34
bhargav_ram30-Dec-03 20:34 
GeneralShellExecute or WinExec!! Pin
abc87630-Dec-03 20:19
abc87630-Dec-03 20:19 
GeneralRe: ShellExecute or WinExec!! Pin
Robert Kuster31-Dec-03 1:17
Robert Kuster31-Dec-03 1:17 
> I am trying to call ShellExecute or WinExec
> in my Win NT service application.
> ... both of them dont work.

ShellExecute and WinExec both work fine and your process gets created. You just don't see the window of your application because it's on a wrong desktop. To modify this tell your service to be interactive:

    Administrative Tools > Component Services > Services (local) >
    > double click your service > Tab: "Log On" > Check: "Allow service to interact with desktop"

Although you will see the application now, it will still run under the local System account (often unwanted). To modify this behaviour use CreateProcessAsUser rather than ShellExecute or WinExec:

STARTUPINFO si;
PROCESS_INFORMATION pi;
 
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = "WinSta0\\Default";
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = 0;
si.wShowWindow = SW_SHOW;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
 
CreateProcessAsUser(hToken,NULL, szMyApp, NULL, NULL, FALSE,
		    0, NULL, NULL, &si, &pi);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
How to get the security token of a logged-on user? There are several ways, but I usually simply *steal* it from explorer.exe (via OpenProcessToken). As an example check the nRunAsLoggedOnUser function here[^] (=some handy service helper routines from CISCO).

RK Smile | :)
Generalhelp in an active x control Pin
safee ullah30-Dec-03 18:51
safee ullah30-Dec-03 18:51 
GeneralDeployment of project Pin
Ming Yan30-Dec-03 18:19
Ming Yan30-Dec-03 18:19 
GeneralRe: Deployment of project Pin
Monty230-Dec-03 18:39
Monty230-Dec-03 18:39 
GeneralRe: Deployment of project Pin
Ming Yan30-Dec-03 18:50
Ming Yan30-Dec-03 18:50 
QuestionHow to use vb ocx in vc++ Pin
percyvimal30-Dec-03 18:10
percyvimal30-Dec-03 18:10 
AnswerRe: How to use vb ocx in vc++ Pin
bryce30-Dec-03 18:24
bryce30-Dec-03 18:24 
GeneralSending Extended ascii character with PostMessage api in vc++ Pin
percyvimal30-Dec-03 18:05
percyvimal30-Dec-03 18:05 
Generalmultithreaded sockets bollocks ;) Pin
bryce30-Dec-03 17:14
bryce30-Dec-03 17:14 
GeneralRe: multithreaded sockets bollocks ;) Pin
Johnny ²30-Dec-03 22:00
Johnny ²30-Dec-03 22:00 
GeneralRe: multithreaded sockets bollocks ;) Pin
bryce31-Dec-03 11:51
bryce31-Dec-03 11:51 
GeneralRe: multithreaded sockets bollocks ;) Pin
valikac31-Dec-03 5:39
valikac31-Dec-03 5:39 
GeneralRe: multithreaded sockets bollocks ;) Pin
bryce31-Dec-03 11:56
bryce31-Dec-03 11:56 
GeneralRe: multithreaded sockets bollocks ;) Pin
valikac1-Jan-04 5:43
valikac1-Jan-04 5:43 
GeneralRe: multithreaded sockets bollocks ;) Pin
bryce5-Jan-04 0:25
bryce5-Jan-04 0:25 
GeneralQuestions about DirectShow programming Pin
youken30-Dec-03 16:58
youken30-Dec-03 16:58 
QuestionCannot access the ClassView information file???? Pin
wow999930-Dec-03 15:17
wow999930-Dec-03 15:17 
AnswerRe: Cannot access the ClassView information file???? Pin
Monty230-Dec-03 16:17
Monty230-Dec-03 16:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.