调用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)
浙公网安备 33010602011771号