Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem to get computer name

Problem to get computer name

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminregexquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cheickna
    wrote on last edited by
    #1

    Hi, Here is a function (above) to browse Computers names on network. It work but I have a problem to get the name of machine which is selected. If i use this call : CString strDir = BrowseForFolder(m_hWnd, "Select a folder", 0 ); with browseInfo.pidlRoot=NULL; I obtain the name of folder selected. BUT WITH THIS CALL CString strDir = BrowseForFolder(m_hWnd, "selected a computer", BIF_BROWSEFORCOMPUTER ); with browseInfo.pidlRoot=(_ITEMIDLIST *)0x12; The function browse very match only computer but my variable strDir is empty at the end. I try to use this other function : SHGetSpecialFolderPath(hWnd,szBuffer,CSIDL_NETHOOD ,0); but i have a entry point problem to shell32.dll Can anybody help me to get computer name? Function ================================================================================ CString& CTestDlg::BrowseForFolder(HWND hWnd, LPCSTR lpszTitle, UINT nFlags) { static CString strResult = ""; LPMALLOC lpMalloc; // pointer to IMalloc if (::SHGetMalloc(&lpMalloc) != NOERROR) return strResult; // failed to get allocator char szDisplayName[_MAX_PATH]; char szBuffer[_MAX_PATH]; BROWSEINFO browseInfo; browseInfo.hwndOwner = hWnd; // set root at Network Neighborhood ( if NULL then set root at Desktop ) browseInfo.pidlRoot = (_ITEMIDLIST *)0x12; browseInfo.pszDisplayName = szDisplayName; browseInfo.lpszTitle = lpszTitle; browseInfo.ulFlags = nFlags; browseInfo.lpfn = NULL; // not used browseInfo.lParam = 0; // not used LPITEMIDLIST lpItemIDList; if ((lpItemIDList = ::SHBrowseForFolder(&browseInfo)) != NULL) { // Get the path of the selected folder from the // item ID list. if (::SHGetPathFromIDList(lpItemIDList, szBuffer)) { // At this point, szBuffer contains the path // the user chose. if (szBuffer[0] == '\0') { // SHGetPathFromIDList failed, or // SHBrowseForFolder failed. //AfxMessageBox(IDP_FAILED_GET_DIRECTORY,MB_ICONSTOP|MB_OK); return strResult; } // We have a path in szBuffer! // Return it. strResult = szBuffer; return strResult; } else { // The thing referred to by lpItemIDList // might not have been a file system object. // For whatever reason, SHGetPathFromIDList // didn't work! //AfxMessageBox(IDP_FAILED_GET_DIRECT

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups