HI!
I need to import the following functions from User32.dll libray
1) OpenWindowStation
In MSDN it is described with argument and return value:
HWINSTA WINAPI OpenWindowsStation(LPTSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess)
2)GetThreadDesktop
MSDN description:
HDESK WINAPI GetThreadDesktop(DWORD dwThreadId)
3) GetUserObjectInformation
MSDN description:
BOOL WINAPI GetUserObjectInformation(HANDLE hObj, int nIndex, PVOID pvInfo, DWORD nLength, LPDWORD lpnLengthNeeded)
I know that dll function import is made like that:
[DllImport("User32.dll", ExactSpelling=true)]
public static extern IntPtr GetThreadDesktop(int dwThreadId);
I. The first problem is how to change variables types for types understood by C# compiler.
II.The second problem - I tried to import API functions from DLL
in a service code, but it gave no effect - when the service goes to the
part of the code containing imported function it doesn't execute it.
While in an application everithing goes fine.
I'll be grateful for any hints...

Import API functions from DLL
WillieSea
tkroll
You are more than welcome always
.
Best Regards,
Rizwan
NickoM
For First Problem:
See these links:
for OpenStation()
http://pinvoke.net/default.aspx/user32.OpenWindowStation
GetThreadDesktop()
http://pinvoke.net/default.aspx/user32.GetThreadDesktop
GetUserObjectInformation()
http://pinvoke.net/default.aspx/user32.GetUserObjectInformation
For Second Question:
I dont think there is any constraint like this.... Not even tried it ever. Try do call some simple function with Pinvoke in a very simple Service and see what happens!
Best of Luck and Best Regards,
Rizwan