C#转VB.NET的一些问题 25

publicclassWindowsEnum{privatedelegateboolWNDENUMPROC(IntPtrhWnd,intlParam);[DllImpor... public class WindowsEnum
{
private delegate bool WNDENUMPROC(IntPtr hWnd, int lParam);
[DllImport("user32.dll")]
private static extern bool EnumWindows(WNDENUMPROC lpEnumFunc, int lParam);
[DllImport("user32.dll")]
private static extern int GetWindowTextW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder lpString, int nMaxCount);
public struct WindowInfo
{
public IntPtr hWnd;
public string szWindowName;
public string szClassName;
}
public WindowInfo[] GetAllDesktopWindows()
{
List<WindowInfo> wndList = new List<WindowInfo>();
EnumWindows(delegate(IntPtr hWnd, int lParam)
{
WindowInfo wnd = new WindowInfo();
StringBuilder sb = new StringBuilder(256);
wnd.hWnd = hWnd;
GetWindowTextW(hWnd, sb, sb.Capacity);
wnd.szWindowName = sb.ToString();
GetClassNameW(hWnd, sb, sb.Capacity);
wnd.szClassName = sb.ToString();
wndList.Add(wnd);
return true;
}, 0);
return wndList.ToArray();
}
}

C#的这段代码如何转换到VB.net 并将其可用啊? 我现在用网站转换到VB.NET 无法使用 大神帮忙转换一下啊 谢谢!
展开
 我来答
1291389703
2015-02-25 · 超过21用户采纳过TA的回答
知道答主
回答量:62
采纳率:50%
帮助的人:26.7万
展开全部
public class WindowsEnum

private delegate function WNDENUMPROC(hwnd as IntPtr, lParam as int32) as boolean

[DllImport("user32.dll")] private shared function EnumWindows( lpEnumFunc as WNDENUMPROC , lParam as int32) as boolean
end function

[DllImport("user32.dll")] private shared function GetWindowTextW(hWnd as IntPtr , lpString as stringbuilder,nMaxCount as int32) as int32
end function

[DllImport("user32.dll")] private shared function GetClassNameW(hWnd as IntPtr , lpString as StringBuilder,nMaxCount as int32 ) as int32
end function

public structure WindowInfo
public hWnd as IntPtr
public szWindowName as string
public szClassNamestring
end structure

public function GetAllDesktopWindows() as WindowInfo()

Dim wndList as new List<of windowinfo>()

EnumWindows(Function(hWnd as IntPtr,lParam as int32)
Dim wnd as new WindowInfo()
Dim sb as new StringBuilder(256)
wnd.hWnd = hWnd
GetWindowTextW(hWnd, sb, sb.Capacity)
wnd.szWindowName = sb.ToString()
GetClassNameW(hWnd, sb, sb.Capacity)
wnd.szClassName = sb.ToString()
wndList.Add(wnd)
return true
End Function,0)

return wndList.ToArray()
end function

end class
更多追问追答
追问
你这个是不可用的!
追答
可能哪里打错了,截个图把
acceyant
2015-02-25 · TA获得超过154个赞
知道答主
回答量:316
采纳率:0%
帮助的人:92.6万
展开全部
其实是这样的.Dim FileName As String =
欢迎交流。
追问
什么意思 帮忙装换一下呗? 使其功能一样!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式