您的位置:程序门 -> vb ->



definedosdevice虚拟的磁盘如何卸载?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


definedosdevice虚拟的磁盘如何卸载?
发表于:2007-01-13 21:07:13 楼主
definedosdevice(0,   "g: ",   "e: ")虚拟了一个g盘,要如何卸载它???
发表于:2007-01-13 21:54:091楼 得分:0
public   declare   function   definedosdevice   lib   "kernel32 "   alias   "definedosdevicea "   (byval   dwflags   as   long,   byval   lpdevicename   as   string,   byval   lptargetpath   as   string)   as   long
                               
sub   tt()
call   definedosdevice(2,   "z: ",   "c:\flashget ")
end   sub


发表于:2007-01-13 21:54:212楼 得分:0
api我还未找到,不过你可   使用   subst   命令
发表于:2007-01-14 09:14:543楼 得分:0
ret   =   definedosdevice(0,   "f: ", "\\ml000\game ") '建立虚拟盘
ret   =   definedosdevice(2,   "f: ",   vbnull) '删除虚拟盘
用这两条语句有时候能成功,有时候又不行,不知道怎么回事。
dwflags参数我用过0、1、2、3、4、8,3也可以删除虚拟盘,不知道怎么回事。
发表于:2007-01-16 14:11:434楼 得分:0
看msdn:

definedosdevice

the   definedosdevice   function   defines,   redefines,   or   deletes   ms-dos   device   names.


bool   definedosdevice(
    dword   dwflags,
    lpctstr   lpdevicename,
    lpctstr   lptargetpath
);

parameters
dwflags  
[in]   controllable   aspects   of   the   definedosdevice   function.   this   parameter   can   be   one   or   more   of   the   following   values.   value   meaning  
ddd_exact_match_on_remove   if   this   value   is   specified   along   with   ddd_remove_definition,   the   function   will   use   an   exact   match   to   determine   which   mapping   to   remove.   use   this   value   to   insure   that   you   do   not   delete   something   that   you   did   not   define.  
ddd_no_broadcast_system   do   not   broadcast   the   wm_settingchange   message.   by   default,   this   message   is   broadcast   to   notify   the   shell   and   applications   of   the   change.  
ddd_raw_target_path   uses   the   lptargetpath   string   as   is.   otherwise,   it   is   converted   from   an   ms-dos   path   to   a   path.  
ddd_remove_definition   removes   the   specified   definition   for   the   specified   device.   to   determine   which   definition   to   remove,   the   function   walks   the   list   of   mappings   for   the   device,   looking   for   a   match   of   lptargetpath   against   a   prefix   of   each   mapping   associated   with   this   device.   the   first   mapping   that   matches   is   the   one   removed,   and   then   the   function   returns.  
if   lptargetpath   is   null   or   a   pointer   to   a   null   string,   the   function   will   remove   the   first   mapping   associated   with   the   device   and   pop   the   most   recent   one   pushed.   if   there   is   nothing   left   to   pop,   the   device   name   will   be   removed.

if   this   value   is   not   specified,   the   string   pointed   to   by   the   lptargetpath   parameter   will   become   the   new   mapping   for   this   device.
 

lpdevicename  
[in]   pointer   to   an   ms-dos   device   name   string   specifying   the   device   the   function   is   defining,   redefining,   or   deleting.   the   device   name   string   must   not   have   a   trailing   colon,   unless   a   drive   letter   (c   or   d,   for   example)   is   being   defined,   redefined,   or   deleted.   in   no   case   is   a   trailing   backslash   allowed.  
lptargetpath  
[in]   pointer   to   a   path   string   that   will   implement   this   device.   the   string   is   an   ms-dos   path   string   unless   the   ddd_raw_target_path   flag   is   specified,   in   which   case   this   string   is   a   path   string.  
return   values
if   the   function   succeeds,   the   return   value   is   nonzero.

if   the   function   fails,   the   return   value   is   zero.   to   get   extended   error   information,   call   getlasterror.

remarks
ms-dos   device   names   are   stored   as   junctions   in   the   object   name   space.   the   code   that   converts   an   ms-dos   path   into   a   corresponding   path   uses   these   junctions   to   map   ms-dos   devices   and   drive   letters.   the   definedosdevice   function   enables   an   application   to   modify   the   junctions   used   to   implement   the   ms-dos   device   name   space.

to   retrieve   the   current   mapping   for   a   particular   ms-dos   device   name   or   to   obtain   a   list   of   all   ms-dos   devices   known   to   the   system,   use   the   querydosdevice   function.

to   define   a   drive   letter   assignment   that   is   persistent   across   boots   and   not   a   network   share,   use   the   setvolumemountpoint   function.   if   the   volume   to   be   mounted   already   has   a   drive   letter   assigned   to   it,   use   the   deletevolumemountpoint   function   to   remove   the   assignment.

drive   letters   and   device   names   defined   at   system   boot   time   are   protected   from   redefinition   and   deletion   unless   the   user   is   an   administrator.


windows   server   2003   and   windows   xp:     the   function   creates   a   device   name   for   a   caller   that   is   not   running   in   the   localsystem   context   in   its   own   local   ms-dos   device   namespace.   if   the   caller   is   running   in   the   localsystem   context,   the   function   creates   the   device   name   in   the   global   ms-dos   device   namespace.   for   more   information,   see   defining   an   ms   dos   device   name.

example   code  
for   an   example,   see   editing   drive   letter   assignments.

发表于:2007-01-16 14:15:565楼 得分:0
ddd_exact_match_on_remove   if   this   value   is   specified   along   with   ddd_remove_definition,   the   function   will   use   an   exact   match   to   determine   which   mapping   to   remove.   use   this   value   to   insure   that   you   do   not   delete   something   that   you   did   not   define.
发表于:2007-01-18 18:11:246楼 得分:0
哭ing,,definedosdevice是麻,么用过,孤陋寡闻了,

不过一般的东东都支持参数的,例如d-tools,,,就可以用shell   c:\xxx\d-tools.exe   -xxxx来加载或卸载虚拟盘..
发表于:2007-07-31 22:01:237楼 得分:0
用这个去删删看definedosdevice(2,   strdisk,   vbnullstring)

我用这个就可以了
发表于:2007-07-31 22:24:438楼 得分:0
有文件在使用中,是删除不成功的
发表于:2007-08-01 08:34:299楼 得分:0
同意   myjian(嗷嗷叫的老马--无业,正在到处游的人.......)   ,这与弹出   usb   disk   一样处理,正在使用就出警告。


快速检索

最新资讯
热门点击