这段代码可能对您有帮助,它可以确定文件夹是否在网络共享上。
#include <windows.h>
#include <stdio.h>
#include <lm.h>
int main()
{
PSHARE_INFO_502 BufPtr, p;
NET_API_STATUS res;
LPTSTR lpszServer = NULL;
DWORD er = 0,tr = 0,resume = 0, i;
do
{
res = NetShareEnum(lpszServer, 502, (LPBYTE *) &BufPtr, -1, &er, &tr, &resume);
if(res == ERROR_SUCCESS || res == ERROR_MORE_DATA)
{
p = BufPtr;
for(i = 1; i <= er; i++)
{
printf("%S %S
", p->shi502_netname, p->shi502_path);
p++;
}
NetApiBufferFree(BufPtr);
}
else
printf("Error: %ld
", res);
}
while(res == ERROR_MORE_DATA);
system("pause");
return 0;
}