Home > Undocumented WinAPI > Showing “Select Computer” dialog, with all network computers listed out!

Showing “Select Computer” dialog, with all network computers listed out!

Ever seen that “Select Computer” dialog coming up and did you wonder how to have all those computer names without writing much code. There is an undocumented exported api in “ntlanman.dll” called ServerBrowseDialogA0 which is used exactly for this purpose.

int main()
{
// Some funky stuff
    HMODULE hMod = LoadLibrary( “Kernel32.dll” );
    GetConsoleWindow GCW = (GetConsoleWindow)GetProcAddress( hMod, “GetConsoleWindow” );
    HWND hConsole = GCW();
    SetWindowText( hConsole, “Nibu” );

// The real stuff for showing the dialog starts here
    HMODULE hModule = LoadLibrary( _T( “ntlanman.dll” ));

    typedef DWORD ( WINAPI *FNNTBrowseDlg )( HWND hwnd,
                                             CHAR *pchBuffer,
                                             DWORD cchBufSize );
    FNNTBrowseDlg lpfn = 0;
    CHAR szT[MAX_PATH + 1] = { 0 };
    lpfn = ( FNNTBrowseDlg )GetProcAddress( hModule, “ServerBrowseDialogA0” );

    // Will return zero on success, now show the dialog
    const DWORD dwResult = lpfn( hConsole, szT, MAX_PATH );

// Check result
    if( !dwResult )
    {
      stringstream sStream;
      sStream < < "Selected computer name is: " << szT;       MessageBox( hConsole, sStream.str().c_str(), "Computer name", MB_OK | MB_ICONINFORMATION );     }     else     {       MessageBox( hConsole, "You didn't make any selection", "Computer name", MB_OK | MB_ICONINFORMATION );     }     FreeLibrary( hModule );     FreeLibrary( hMod ); return 0; }// End main[/sourcecode] Output:

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: