Click here to Skip to main content
15,914,373 members
Home / Discussions / C#
   

C#

 
GeneralRe: Binding DataReader to DataGrid Pin
S Palip6-Jun-07 16:07
S Palip6-Jun-07 16:07 
QuestionPrint PDF via AcrobatReader and close it afterwards Pin
blackjack21506-Jun-07 1:11
blackjack21506-Jun-07 1:11 
AnswerRe: Print PDF via AcrobatReader and close it afterwards Pin
Seishin#6-Jun-07 1:50
Seishin#6-Jun-07 1:50 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
ScottM16-Jun-07 2:01
ScottM16-Jun-07 2:01 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
Seishin#6-Jun-07 2:12
Seishin#6-Jun-07 2:12 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
blackjack21506-Jun-07 2:01
blackjack21506-Jun-07 2:01 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
ScottM16-Jun-07 2:19
ScottM16-Jun-07 2:19 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
jethomas414-Oct-09 6:07
jethomas414-Oct-09 6:07 
GeneralRe: Print PDF via AcrobatReader and close it afterwards Pin
blackjack215015-Oct-09 1:08
blackjack215015-Oct-09 1:08 
QuestionRe: Print PDF via AcrobatReader and close it afterwards Pin
M. J. Jaya Chitra7-Jun-07 18:12
M. J. Jaya Chitra7-Jun-07 18:12 
Questionwant to change the property of column header in datagridview Pin
devesh_code6-Jun-07 0:17
devesh_code6-Jun-07 0:17 
AnswerRe: want to change the property of column header in datagridview Pin
Praveen Raghuvanshi6-Jun-07 0:43
professionalPraveen Raghuvanshi6-Jun-07 0:43 
GeneralRe: want to change the property of column header in datagridview Pin
devesh_code6-Jun-07 2:38
devesh_code6-Jun-07 2:38 
QuestionWindows service communication` Pin
M. J. Jaya Chitra6-Jun-07 0:05
M. J. Jaya Chitra6-Jun-07 0:05 
AnswerRe: Windows service communication` Pin
ganti.r6-Jun-07 1:02
ganti.r6-Jun-07 1:02 
AnswerRe: Windows service communication` Pin
WillemM6-Jun-07 1:03
WillemM6-Jun-07 1:03 
QuestionRe: Windows service communication` Pin
M. J. Jaya Chitra6-Jun-07 1:09
M. J. Jaya Chitra6-Jun-07 1:09 
AnswerRe: Windows service communication` Pin
Not Active6-Jun-07 1:21
mentorNot Active6-Jun-07 1:21 
AnswerRe: Windows service communication Pin
PavanPareta6-Jun-07 1:24
PavanPareta6-Jun-07 1:24 
AnswerRe: Windows service communication` Pin
kubben6-Jun-07 1:41
kubben6-Jun-07 1:41 
QuestionHow to get the full username? Pin
User 26989675-Jun-07 23:14
User 26989675-Jun-07 23:14 
Hello together,

I have to get the full username. My solution only gets it for local users but I need it also when the user is logged in by a domain account. Has anybody an idea how do get this?

using System;<br />
using System.Runtime.InteropServices;<br />
<br />
namespace UserInfo<br />
{<br />
  public class Program<br />
  {<br />
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]<br />
    public struct USER_INFO<br />
    {<br />
      [MarshalAs(UnmanagedType.LPWStr)]<br />
      public String username;<br />
      [MarshalAs(UnmanagedType.LPWStr)]<br />
      public String password;<br />
      [MarshalAs(UnmanagedType.LPWStr)]<br />
      public String comment;<br />
      [MarshalAs(UnmanagedType.LPWStr)]<br />
      public String fullname;<br />
    }<br />
<br />
    [DllImport("Netapi32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]<br />
    private extern static Int32 NetUserGetInfo(<br />
      [MarshalAs(UnmanagedType.LPWStr)] String ServerName,<br />
      [MarshalAs(UnmanagedType.LPWStr)] String UserName,<br />
      Int32 level,<br />
      out IntPtr BufPtr);<br />
<br />
    [DllImport("Netapi32.dll", SetLastError = true)]<br />
    static extern Int32 NetApiBufferFree(IntPtr Buffer);<br />
<br />
    public static String GetFullname()<br />
    {<br />
      String retVal = String.Empty;<br />
<br />
      try<br />
      {<br />
        // Create an new instance of the USER_INFO struct.<br />
        USER_INFO objUserInfo = new USER_INFO();<br />
        IntPtr bufPtr; // Because it's an OUT, we don't need to alloc.<br />
        Int32 lngReturn = NetUserGetInfo(Environment.MachineName, Environment.UserName, 10, out bufPtr);<br />
        if (lngReturn == 0)<br />
        {<br />
          objUserInfo = (USER_INFO)Marshal.PtrToStructure(bufPtr, typeof(USER_INFO));<br />
          retVal = objUserInfo.fullname;<br />
        }<br />
        NetApiBufferFree(bufPtr);<br />
        bufPtr = IntPtr.Zero;<br />
      }<br />
      catch (Exception ex)<br />
      {<br />
        Console.WriteLine("GetFullname: " + ex.Message);<br />
      }<br />
      <br />
      return retVal;<br />
    }<br />
<br />
    public static void Main(String[] args)<br />
    {<br />
      Console.WriteLine("Login name: " + Environment.UserName);<br />
      Console.WriteLine("Full username: " + GetFullname());<br />
      Console.ReadLine();<br />
    }<br />
  }<br />
}


Greets
Patrick
AnswerRe: How to get the full username? Pin
ScottM15-Jun-07 23:58
ScottM15-Jun-07 23:58 
QuestionLaunching application through local network from another PC Pin
sgeorgije5-Jun-07 22:10
sgeorgije5-Jun-07 22:10 
GeneralRe: Launching application through local network from another PC Pin
ScottM15-Jun-07 23:52
ScottM15-Jun-07 23:52 
GeneralRe: Launching application through local network from another PC Pin
sgeorgije6-Jun-07 1:11
sgeorgije6-Jun-07 1:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.