Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ComboBox_SetCurSel位于哪个DLL中?_C#_Winapi_Pinvoke - Fatal编程技术网

C# ComboBox_SetCurSel位于哪个DLL中?

C# ComboBox_SetCurSel位于哪个DLL中?,c#,winapi,pinvoke,C#,Winapi,Pinvoke,我想在我的C#应用程序中使用WinApi函数ComboBox_SetCurSel 为此,我插入以下声明: [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr ComboBox_SetCurSel(IntPtr hWnd, int index); 当我运行程序时,我得到了错误 EntryPointNotFoundException ComboBox_SetCurSel user32.dll Me

我想在我的C#应用程序中使用WinApi函数
ComboBox_SetCurSel

为此,我插入以下声明:

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr ComboBox_SetCurSel(IntPtr hWnd, int index);
当我运行程序时,我得到了错误

EntryPointNotFoundException ComboBox_SetCurSel user32.dll
  Message=Can't find entry point "ComboBox_SetCurSel" in DLL "user32.dll".
我想这个错误是由于
组合框\u SetCurSel
不在
user32.dll中,而是在其他一些dll中引起的

如果这是正确的,要修复此错误,我需要更改
DllImport
声明


问题:
ComboBox\u SetCurSel
位于哪个DLL中?

这实际上不是一个函数。这是一个宏,来自WindowsX.h:

#define ComboBox_SetCurSel(hwndCtl, index)          ((int)(DWORD)SNDMSG((hwndCtl), CB_SETCURSEL, (WPARAM)(int)(index), 0L))
其中SNDMSG是SendMessage。换句话说,你应该做:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);

SendMessage(hWnd, 0x14E, (Int32)index, 0);

这实际上不是一个函数。这是一个宏,来自WindowsX.h:

#define ComboBox_SetCurSel(hwndCtl, index)          ((int)(DWORD)SNDMSG((hwndCtl), CB_SETCURSEL, (WPARAM)(int)(index), 0L))
其中SNDMSG是SendMessage。换句话说,你应该做:

[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);

SendMessage(hWnd, 0x14E, (Int32)index, 0);

ComboBox_SetCurSel是宏,不能在C#中使用。使用CB_SETCURSEL消息调用SendMessage API:


这是SendMessage API声明:

ComboBox_SetCurSel是宏,不能在C#中使用它。使用CB_SETCURSEL消息调用SendMessage API:

这是SendMessage API声明:

请参见:

这是一个宏,不是函数。

请参见:

这是一个宏,不是一个函数