能力值:
( LV2,RANK:10 )
|
-
-
2 楼
void EnumShareResources() { //PSHARE_INFO_1 pShareTmp=NULL,pShareBuffer=NULL; PSHARE_INFO_0 pShareTmp=NULL,pShareBuffer=NULL; NET_API_STATUS netApiStat=ERROR_SUCCESS; DWORD dwEr=0,dwTr=0,dwResume=0,i=0,dwEnumOpenStat=0,dwEnumEnumStat=0; char* pcHost=(char*)calloc(64,sizeof(char)); LPWSTR szWideIp=(LPWSTR)calloc(32,sizeof(WCHAR)); BOOL bFind=FALSE; sprintf(pcHost,"%d.%d.%d.%d",192,168,10,183); //GetHostNameByIp(pcHost); //i=MultiByteToWideChar(CP_ACP,0,pcIp,-1,NULL,0); MultiByteToWideChar(CP_ACP,0,pcHost,-1,szWideIp,64); memcpy(pcHost,szWideIp,64); do { //netApiStat=NetShareEnum(pcHost,1,(LPBYTE*)&pShareBuffer,-1,&dwEr,&dwTr,&dwResume); netApiStat=NetShareEnum(pcHost,0,(LPBYTE*)&pShareBuffer,-1,&dwEr,&dwTr,&dwResume); if (netApiStat==ERROR_MORE_DATA||netApiStat==ERROR_SUCCESS) { pShareTmp=pShareBuffer; for (i=0;i<dwEr;i++) { //wprintf(L"%-20s%-8d%-20s",pShareTmp->shi1_netname,pShareTmp->shi1_type,pShareTmp->shi1_remark); wprintf(L"%20s",pShareTmp->shi0_netname); printf("\r\n"); pShareTmp++; } NetApiBufferFree(pShareTmp); }
} while (netApiStat==ERROR_MORE_DATA); }
知道SHARE_INFO_1与SHARE_INFO_502各自不同的用途之后解决了。
|