Problem to get computer name
-
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