请教关于如何使共享立即生效的问题!!!(100分)(100分)

  • 主题发起人 主题发起人 ev_huang
  • 开始时间 开始时间
E

ev_huang

Unregistered / Unconfirmed
GUEST, unregistred user!
我们都知道通过右击鼠标来使某个文件夹共享,共享是立即生效的。但我自己写了个共享文件夹的程序,原理是修改注册表,但这样一定要重新启动机器才能使共享生效。我想请教各位,如何才能在自己的程序中使共享立即生效呢?(就像共享蠕虫病毒那样,难道共享蠕虫用的不是修改注册表的方法?),别告诉我用net share命令,因为在Win9X中无此命令。我比较过通过鼠标使文件夹共享和修改注册表使文件夹共享的方式,两种方式在注册表中的改动是一样的,我猜想用鼠标确认的时候不仅改了注册表,而且还执行了其他的功能使共享立即生效(文件夹马上出现共享的小手图标)。我想知道的是原理,并非要程序。拜托大家啦,谢谢!
 
The share functions control shared resources. A shared resource is a local resource on a server (for example, a disk directory, print device, or named pipe) that can be accessed by users and applications on the network. The share functions are:

NetShareAdd Shares a resource on a server.
NetShareCheck Queries whether a server is sharing a device.
NetShareDel Deletes a share name from a server's list of shared resources.
NetShareEnum Retrieves share information about each shared resource on a server.
NetShareGetInfo Retrieves information about a specified shared resource on a server.
NetShareSetInfo Sets a shared resource's parameters.


The WNetEnumResource function should be used instead of the NetShareEnum function, which is obsolete.
The NetShareAdd function allows a user or application to share a resource of a specific type using the specified share name. The NetShareAdd function requires the share name and local device name to share the resource. A user or application must have an account on the server to access the resource.
You may also specify a Security Descriptor to be associated with a share, which specifies which users will be allowed to access files through this share, and with what type of access.

LAN Manager defines three types of special share names for interprocess communication (IPC) and remote administration of the server:

?IPC$, reserved for interprocess communication.
?ADMIN$, reserved for remote administration.
?A$, B$, C$ (and other local disk names followed by a dollar sign), assigned to local disk devices.



Share functions are available at four information levels:
SHARE_INFO_0
SHARE_INFO_1
SHARE_INFO_2
SHARE_INFO_502
The following information levels are valid only for NetShareSetInfo:
SHARE_INFO_1004
SHARE_INFO_1006
The following is supported only on Windows NT:
SHARE_INFO_1501
For NetShareSetInfo, parmnum values refer to the members of the SHARE_INFO structure, as follows. These values are used when indicating an error in a specific parameter through parm_err.

parmnum value Member of SHARE_INFO structure
SHARE_NETNAME_PARMNUM shi_netname
SHARE_TYPE_PARMNUM shi_type
SHARE_REMARK_PARMNUM shi_remark
SHARE_PERMISSIONS_PARMNUM shi_permissions
SHARE_MAX_USES_PARMNUM shi_max_uses
SHARE_CURRENT_USES_PARMNUM shi_current_uses
SHARE_PATH_PARMNUM shi_path
SHARE_PASSWD_PARMNUM shi_passwd
SHARE_FILE_SD_PARMNUM shi_security_descriptor
 
我猜是因为你修改了注册表没有通知系统的原因:用下面的API通知系统(可能要用到ShellApi单元)你试试吧,我没试过:
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
具体用法可以用SHChangeNotify为关键字搜一下。呵呵,我比较懒。
如何可以的话吱一声,告诉我一下
 
我刚才试过,用SHChangeNotify函数要加上shlobj单元,但是没有用,还是出现不了共享的小手图标,非要重新启动机器才行,哪位大侠能指点下我啊!!!
 
算是好人做到底了.98下的网络管理源代码:
http://evan.zhibo.net/delphi/LanManager.zip
 
To:999roseto347,用Delphi7执行里面的Demo时,总提示"[Fatal Error] NetWatchMain.pas(7): File not found: 'svrapi.dcu'"。我就想知道最简单的那一步,即修改注册表进行文件夹共享后如何通知Windows使之立即生效。拜托了!
 
File not found: 'svrapi.dcu>>>>>你可以在Tools-》环境选项中的-》library的library path 增加一个指向解压缩后的pas目录。(里面有svrapi.dcu)
(或把svrapi.dcu拷过去,这我没试过。)
我就想知道最简单的那一步,即修改注册表进行文件夹共享后如何通知Windows使之立即生效。》》》》》》我也不懂,所以无能为力。
上面的例子里面有你要的东西。我还没具体看。所以只好你自己努力一下了。
 
如果再出错就不要理他,找你要的代码要紧。
 
后退
顶部