bruce168

博客园 首页 新随笔 联系 订阅 管理

调用Win32组件:

C#:

[DllImport("advapi32.dll", EntryPoint="GetUserNameA", CharSet=CharSet.Ansi, SetLastError=true, ExactSpelling=true)]
public static extern int getUserName(string lpBuffer, ref int nSize);

 

VB.Net:

<DllImport("advapi32.dll", EntryPoint:="GetUserNameA", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)> _
Public Shared Function getUserName(ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
End Function

 

调用COM组件:

C#:

dynamic o = Activator.CreateInstance(Type.GetTypeFromProgID("WScript.Network"));

MessageBox.Show(o.UserName);

VB.Net:

Dim o As Object = Activator.CreateInstance(Type.GetTypeFromProgID("WScript.Network"))

MessageBox.Show(o.UserName)

posted on 2011-10-18 15:15  健彬~Wong  阅读(360)  评论(0)    收藏  举报