转RasGetEntryProperties API函数。在http://www.pinvoke.net/default.aspx/rasapi32.RasGetEntryProperties
中转成
[DllImport("rasapi32.dll", CharSet = CharSet.Auto)]
private static extern UInt32 RasGetEntryProperties(
   string lpszPhoneBook,
   string szEntry,
   IntPtr lpbEntry,
   ref UInt32 lpdwEntrySize,
   IntPtr lpb,
   IntPtr lpdwSize);
但是这个函数的原型第三个参数是LPRASENTRY lpRasEntry,RasEntry结构体的缓冲区。修改如下:
[DllImport("rasapi32.dll", CharSet = CharSet.Auto)]
public static extern uint RasGetEntryProperties(
                    string lpszPhoneBook,
                    string szEntry,
                    [In,Out]RasEntry[] lpRasEntry,
                    ref UInt32 lpdwEntrySize,
                    IntPtr lpb,      
                    IntPtr lpdwSize);
这两种形式都出现错误。RasGetEntryProperties 函数的返回值是ERROR_INVALID_SIZE,Marshal.GetLastWin32Error的返回
值是ERROR_PROC_NOT_FOUND。
请帮忙!谢谢

解决方案 »

  1.   

    一、拖动无标题窗体:包含头文件:#include $#@60;winuser.h$#@62;在窗体或组件的 OnMouseDown 事件中加入以下代码:if(Button == mbLeft)
    {
    ReleaseCapture();
    SendMessage( Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
    }二、弹出和关闭光驱:包含头文件:#include $#@60;mmsystem.h$#@62;在窗体的OnCreate事件中加入:mciSendString("open cdaudio alias cd wait shareable",0,0,0);1、要弹出光驱时使用:mciSendString("set cd door open",0,0,0);2、要关闭光驱时使用:mciSendString("set cd door closed",0,0,0);三、提取图标:包含头文件:#include $#@60;shellapi.h$#@62;例子:TIcon *Icon = new TIcon();
    AnsiString FileName = "C:\\WINDOWS\\SYSTEM\\SHELL32.DLL";
    int TotalIcon;//得到文件SHELL32.DLL的总图标数
    TotalIcon = (int)ExtractIcon(Form1->Handle,FileName.c_str(), -1);//提取第一个图标,0为第一个,1为第二个,类推...
    Icon->Handle = ExtractIcon( Form1->Handle, FileName.c_str(), 0);//保存图标
    Icon->SaveToFile("C:\\1.ICO");四、设置顶端窗口(永在上面):包含头文件:#include $#@60;winuser.h$#@62;1、设置顶层窗口SetWindowPos( Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE||SWP_NOSIZE);2、取消顶层窗口SetWindowPos( Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE||SWP_NOSIZE);