得到了文件夹的路径来判断它是否为共享文件夹
解决方案 »
- 关于文本根据编辑框的宽度实现自动换行?
- 如何让程序时间指定日期间隔触发某个事件?
- 请教关于在MDI中,如何在CView视图关联的菜单中动态添加菜单项。
- 如何使ActiveX控件画出进度条?
- 关于TRACE 语句,请大神帮忙~~~
- [[[如何得知一个网页的编码]]]?
- 在类中使用多线程的问题(beginthread)
- 请教高手!如何将Outlook中几句VBScript语句改成VC++?!
- 弄不明白,详情http://expert.csdn.net/Expert/topic/2078/2078080.xml?temp=.6914484
- 如何CStatic控件中绘制一条直线?
- 一个字母值50分!
- CPU类型用什么类可以知道?
98/me:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Network\LanMan\2K/XP:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\lanmanserver\Shares
HKEY key/*根键*/,CString lpsubkey/*目录*/,
CString keyname/*待读键名*/,DWORD type/*键值类型*/,
void* address,DWORD count)
{
HKEY hkey;
DWORD atype,size;
LONG l=RegCreateKeyEx(key,lpsubkey,0,NULL,REG_OPTION_NON_VOLATILE,
KEY_CREATE_SUB_KEY|KEY_WRITE|KEY_READ,NULL,&hkey,NULL);
if (l!=ERROR_SUCCESS)
{
RegCloseKey(hkey);
return false;
}
size=MAX_PATH;
if (RegQueryValueEx(hkey,keyname,0,&atype,(BYTE*)address,&count)!=ERROR_SUCCESS)
return false;
return true;
}
Windows 95/98: The following code sample demonstrates how to list information about each shared resource on a server with a call to the NetShareEnum function.The sample allocates the memory required to receive 20 share_info_50 structures. If this size is inadequate, the sample warns the caller that there are more entries to enumerate. Finally, the sample frees the allocated memory.#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <svrapi.h>const short MAX_ENTRIES = 20;int main(int argc, char FAR * argv[])
{
char FAR * pszServerName = NULL;
short nLevel = 50;
struct share_info_50* pBuf = NULL;
struct share_info_50* pTmpBuf = NULL;
short cbBuffer;
short nEntriesRead = 0;
short nTotalEntries = 0;
short nTotalCount = 0;
int i;
NET_API_STATUS nStatus;
//
// ServerName can be NULL to indicate the local computer.
//
if (argc > 2)
{
printf("Usage: %s [\\\\ServerName]\n", argv[0]);
exit(1);
} if (argc == 2)
pszServerName = argv[1];
//
// Allocate the memory required to receive a maximum of
// 20 share_info_50 structures.
//
cbBuffer = MAX_ENTRIES * sizeof(struct share_info_50); pBuf = malloc(cbBuffer); if (pBuf == NULL)
printf("No memory\n");
//
// Call the NetShareEnum function to list the
// shares, specifying information level 50.
//
nStatus = NetShareEnum(pszServerName,
nLevel,
(char FAR *)pBuf,
cbBuffer,
&nEntriesRead,
&nTotalEntries);
//
// Loop through the entries; process errors.
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
for (i = 0; (i < nEntriesRead); i++)
{
assert(pTmpBuf != NULL); if (pTmpBuf == NULL)
{
fprintf(stderr, "An access violation has occurred\n");
break;
}
//
// Display the information for each entry retrieved.
//
printf("\n\tShare: %s\n", pTmpBuf->shi50_netname);
printf("\tPath: %s\n", pTmpBuf->shi50_path); pTmpBuf++;
nTotalCount++;
}
}
}
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Display a warning if the buffer was not large enough
// to contain all available entries.
//
if ((nEntriesRead < nTotalEntries) || (nStatus == ERROR_MORE_DATA))
fprintf(stderr, "Not all entries have been enumerated\n");
//
// Free the allocated memory.
//
if (pBuf != NULL)
free(pBuf); fprintf(stderr, "\nTotal of %d entries enumerated\n", nTotalCount); return 0;
}