[ maximus_1 @ 19.08.2006. 14:06 ] @
Treba mi neka funkcija kojom bih mogao saznati koji su sve user accounti na xpu i koji je trenutno aktivan (sa kojeg se izvodi aplikacija).
[ icobh @ 19.08.2006. 14:26 ] @
Koji sve useri postoje ne znam kako a koji je trenutno aktivan, imaš ovaj dole napisani kod u basicu, možeš ga prevesti u C++ veoma lako:

Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Form_Load()

    Dim strTemp As String, strUserName As String

    'Create a buffer
    strTemp = String(100, Chr$(0))

    'Get the temporary path
    GetTempPath 100, strTemp

    'strip the rest of the buffer
    strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)

    'Create a buffer
    strUserName = String(100, Chr$(0))

    'Get the username
    GetUserName strUserName, 100

    'strip the rest of the buffer
    strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)

    'Show the temppath and the username
    MsgBox "Hello " + strUserName + Chr$(13) + "The temp. path is " + strTemp

End Sub


Izvor: VB API Guide 3.7
[ X Files @ 19.08.2006. 15:14 ] @
Probaj ovako:
Code:

// ...
#include <lmaccess.h>
#include <lmapibuf.h>
// ...
void __fastcall TForm1::Button1Click(TObject *Sender)
{
   ListBox1->Items->Clear();
   DWORD EntriesRead, TotalEntries;
   USER_INFO_1 *UserInfo = NULL;
   DWORD ResumeHandle = 0;
   NET_API_STATUS NetApiStatus;

   do
   {
      NetApiStatus = NetUserEnum( NULL, 1, 0, (LPBYTE*)&UserInfo, 0, &EntriesRead, &TotalEntries, &ResumeHandle );

      for ( DWORD Counter = 0; Counter < EntriesRead; Counter++ )
      {
         AnsiString UserDetails = WideString( UserInfo[Counter].usri1_name ) + ", " +
                                  IntToStr( UserInfo[Counter].usri1_flags ) + ", " +
                                  WideString(UserInfo[Counter].usri1_comment );
         ListBox1->Items->Add( UserDetails );
      }

      NetApiBufferFree( UserInfo );
   }

   while( NetApiStatus == ERROR_MORE_DATA );
}



[Ovu poruku je menjao X Files dana 19.08.2006. u 17:30 GMT+1]