2009-03-03 4 views

Répondre

0

Had à P-Invoke ...

[DllImport("secur32.dll", SetLastError = true, CharSet = CharSet.Auto)] 
    static extern bool GetComputerObjectName(int nameFormat, StringBuilder lpNameBuffer, ref int lpnSize); 

    public static string GetComputerObjectName() 
    { 
     const int NameUniqueId = 6; 
     var lpBuffer = new StringBuilder(260); 
     var bufferLength = lpBuffer.Capacity; 

     if (!GetComputerObjectName(NameUniqueId, lpBuffer, ref bufferLength)) 
     { 
      throw new Win32Exception(Marshal.GetLastWin32Error()); 
     } 

     return lpBuffer.ToString(); 
    } 
2

System.Environment.MachineName?

+0

Je voulais NameUniqueId, pas le nom NetBIOS – galets

+0

Désolé, je ne peux pas trouver comment vous pouvez le faire sans PInvoke. –

Questions connexes