Click here to Skip to main content
15,892,643 members
Home / Discussions / C#
   

C#

 
GeneralRe: Launching GUI from Windows Service Pin
Randhir Sinha12-Oct-03 21:52
Randhir Sinha12-Oct-03 21:52 
GeneralHighliting text Pin
Srikar Y12-Oct-03 18:31
Srikar Y12-Oct-03 18:31 
Questionhow to catch exception throw inside in worker thread? Pin
zecodela12-Oct-03 16:31
zecodela12-Oct-03 16:31 
AnswerRe: how to catch exception throw inside in worker thread? Pin
Randhir Sinha12-Oct-03 22:04
Randhir Sinha12-Oct-03 22:04 
GeneralRe: how to catch exception throw inside in worker thread? Pin
zecodela12-Oct-03 22:19
zecodela12-Oct-03 22:19 
GeneralRunning forms on seperate thead Pin
SharpKnight12-Oct-03 11:34
SharpKnight12-Oct-03 11:34 
GeneralRe: Running forms on seperate thead Pin
12-Oct-03 21:33
suss12-Oct-03 21:33 
GeneralPInvoke CreateProcess Pin
devvvy12-Oct-03 9:31
devvvy12-Oct-03 9:31 
Trying to PInvoke CreateProcess, I looked up MSDN, it says library is "Kernel32.lib" - which is what I specified in my DllImport attribute. I keep getting the following exception:
"Unable To Load Dll"

I'm suspecting:
a. Shouldn't I be loading dll? Not lib? Anyway, another reference suggested to load "coredll.dll" (which is nowhere to be found on my XP)
b. return Type for CreateProcess is of type BOOL. In my C# code, I convert that to "int". Is this correct? Perhaps PInvoke failed because function signature doesn't match? I had same problem when I switched to BOOL. Also, does it matter if I use "class" (instead of struct) for "ProcessInfo"?

Here's what I did, can you see anything wrong here?

public Int32 GetPInvokeError()
{
return GetLastError();
}

//************ PInvoke ************ //
[StructLayout(LayoutKind.Sequential)]
public struct ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}

// Launch a process:
[DllImport("Kernel32.lib", SetLastError=true)]
private extern static int CreateProcess(
String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

// GetLastError:
[DllImport("Kernel32.lib")]
private extern static Int32 GetLastError();


norm
GeneralRe: PInvoke CreateProcess Pin
devvvy12-Oct-03 9:54
devvvy12-Oct-03 9:54 
GeneralRe: PInvoke CreateProcess Pin
J. Dunlap12-Oct-03 9:57
J. Dunlap12-Oct-03 9:57 
GeneralRe: PInvoke CreateProcess Pin
devvvy12-Oct-03 10:00
devvvy12-Oct-03 10:00 
GeneralPInvoke CWnd Pin
devvvy12-Oct-03 10:24
devvvy12-Oct-03 10:24 
GeneralRe: PInvoke CWnd Pin
J. Dunlap12-Oct-03 10:48
J. Dunlap12-Oct-03 10:48 
GeneralRe: PInvoke CWnd Pin
devvvy12-Oct-03 10:52
devvvy12-Oct-03 10:52 
GeneralRe: PInvoke CWnd Pin
Nick Parker12-Oct-03 11:00
protectorNick Parker12-Oct-03 11:00 
GeneralRe: PInvoke CWnd Pin
devvvy12-Oct-03 11:06
devvvy12-Oct-03 11:06 
Generaladding components to the designer by code Pin
Roger Alsing12-Oct-03 2:40
Roger Alsing12-Oct-03 2:40 
GeneralRe: adding components to the designer by code Pin
Rod O12-Oct-03 5:03
Rod O12-Oct-03 5:03 
GeneralRe: adding components to the designer by code Pin
Roger Alsing12-Oct-03 22:10
Roger Alsing12-Oct-03 22:10 
GeneralCOM+ Pin
devvvy12-Oct-03 1:20
devvvy12-Oct-03 1:20 
GeneralMicrothreads Pin
bjoernen12-Oct-03 0:58
bjoernen12-Oct-03 0:58 
GeneralRe: Microthreads Pin
Blake Coverett12-Oct-03 3:01
Blake Coverett12-Oct-03 3:01 
GeneralRe: Microthreads Pin
Bo Hunter12-Oct-03 7:05
Bo Hunter12-Oct-03 7:05 
GeneralRe: Microthreads Pin
bjoernen12-Oct-03 8:13
bjoernen12-Oct-03 8:13 
GeneralCOM+ and remoting Pin
devvvy11-Oct-03 23:31
devvvy11-Oct-03 23:31 

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.