在C#中调用API函数出错的问题
[DllImport("User32.dll")]
public static extern IntPtr CreateDesktop(string lpszDesktop,string lpszDevice,object pDevmode,int dwFlags, long dwDesiredAccess, ref SECURITY_ATTRIBUTES lpsa);
[StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public object lpSecurityDescriptor;
public int bInheritHandle;
}
...
SECURITY_ATTRIBUTES s;
s.nLength = Marshal.SizeOf(s);
s.lpSecurityDescriptor = new object();
s.bInheritHandle = 1;
...
string str1 = "@%@";
string str2 = "%@&*";
object o = new object();
CreateDesktop(str1,str2,o,0, 0x10000000L, ref s);
提示错误:未能将对象引用设置对对象实例.我怎么也没找到空引用..不知错在哪里.
另外,API中的SwithDesktop,CloseDesktop函数究竟是干什么用的?网吧管理软件中的虚拟桌面是用这类API做的吗?
Thanks in Advance!!