WINDOWS核心编程之进程(二)

大笑微笑生气吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头吐舌头生气微笑大笑


偷笑我爱北京天安门偷笑


偷笑天安门上太阳升偷笑


偷笑伟大领袖毛主席偷笑


偷笑指引我们向前进偷笑

偷笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑大笑偷笑

<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>2004年7月14日&nbsp; 晚20:30</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4></FONT></SPAN>&nbsp;</P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT color=#ff1493 size=4>1.进程的实例句柄</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">加载到进程地址空间的每个可执行文件或</SPAN><SPAN lang=EN>DLL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件均被产生一个唯一的实例句柄,就是</SPAN><SPAN lang=EN>hinstExe</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数</SPAN><SPAN lang=EN>.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有些这个参数的类型为</SPAN><SPAN lang=EN>HMODULE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类型,</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注意</SPAN><SPAN lang=EN>:</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这两个类型是完全相同的对象。原因在于</SPAN><SPAN lang=EN>16</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">位的</SPAN><SPAN lang=EN>Windows</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中,</SPAN><SPAN lang=EN>HMODULE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN>HINSTANCE</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用于标识不同的东西。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当你在</SPAN><SPAN lang=EN>vc</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的环境里的</SPAN><SPAN lang=EN>link</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里</SPAN><SPAN lang=EN>category</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">选</SPAN><SPAN lang=EN>ouput</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有个</SPAN><SPAN lang=EN>base ,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这标识着可执行文件的映像加载到的基地址</SPAN><FONT color=#ff0000><SPAN lang=EN>.vc</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">链接程序使用的默认基地址是</SPAN><SPAN lang=EN>0x00400000,</SPAN></FONT><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT color=#ff0000>这是最低地址</FONT>,如果指定应确保在</SPAN><SPAN lang=EN>0x00400000</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或大于这个地址。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要得到这个地址的值可以用</SPAN><SPAN lang=EN>HMODULE GetModuleHandle(PCTSTR pszModule)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数处理。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>pszModule</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就是可执行文件或</SPAN><SPAN lang=EN>dll</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件的名字,返回就是加载到进程的基地址。如果设定此参数为</SPAN><SPAN lang=EN>NULL, </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回的就是可执行文件的基地址了。</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注意</SPAN><SPAN lang=EN>:</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可执行文件映像的基地址与可执行文件的基地址的区别</SPAN><SPAN lang=EN>.</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#ff0000><FONT size=4><SPAN lang=EN>GetModuleHandle</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数的两个重要特性</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#ff0000><FONT size=4><SPAN lang=EN>1.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果调用进程不使用常用的对话框函数</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么调用</SPAN><SPAN lang=EN>GetModuleHandle</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并为它传递</SPAN><SPAN lang=EN>:ComDlg<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chmetcnv TCSC="0" NumberType="1" Negative="False" HasSpace="False" SourceValue="32" UnitName="&#8221;" w:st="on">32&#8221;</st1:chmetcnv></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就会返回</SPAN><SPAN lang=EN>NULL, </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">尽管</SPAN><SPAN lang=EN>ComDlg32.dll</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可能加载到了其它进程的地址空间</SPAN><SPAN lang=EN>.</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#ff0000><FONT size=4><SPAN lang=EN>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">.如果</SPAN><SPAN lang=EN>GetModuleHandle(NULL)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN lang=EN>dll</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中调用,返回的也是可执行文件的基地址,而不是</SPAN><SPAN lang=EN>DLL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件的基地址</SPAN><SPAN lang=EN>.</SPAN></FONT></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT color=#ff1493 size=4>2.进程的命令行</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">要获得一个指向进程的完整命令行的指针</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以用</SPAN><SPAN lang=EN>GetCommandLine</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>GetCommandLine();</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数返回一个指向包含完整命令行的缓存的指针</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是个完整路径名</SPAN><SPAN lang=EN>.</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">再介绍个函数</SPAN><SPAN lang=EN><FONT color=#ff0000>CommandLineToArgv</FONT>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它是将字符串分割成它的各个标记</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比如</SPAN><SPAN lang=EN>argc,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其返回一个字符串指针的数组</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>PWSTR CommandLineToArgv(PWSTR pszCmdLine, int* pNumArgs);</FONT></SPAN></P><SPAN lang=EN><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>pNumArgs</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是整数地址</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设置为命令行中参数的数目</SPAN><SPAN lang=EN>.</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN lang=EN>CommaneLineToArgv</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">负责在内部分配内存</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用程序不释放该内存</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">它是在进程运行终止时由</SPAN><SPAN lang=EN>os</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来释放的</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果子自已来释放</SPAN><SPAN lang=EN>,</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用</SPAN><SPAN lang=EN>HeapFree</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><o:p><FONT size=4>&nbsp;</FONT></o:p></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT color=#ff1493 size=4>3.进程的环境变量</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每个进程都有一个与它相关的环境块</SPAN><SPAN lang=EN>.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境块是进程的地址空间中分配的一个内存块</SPAN><SPAN lang=EN>.</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每个环境块都包含一组字符串</SPAN><SPAN lang=EN>.</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>例如</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>VarName1 = VarValue1/0</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>VarName2 = VarValue2/0</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>/0</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>注意</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>例如</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>XYZ= Windows</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>ABC=Windows</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=4><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">虽然</SPAN><SPAN lang=EN>XYZ</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</SPAN><SPAN lang=EN>ABC</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有相同的值,但二者是不同的</SPAN><SPAN lang=EN>.</SPAN></FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>XYZ =Home</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN><FONT size=4>XYZ=Work</FONT></SPAN></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT size=4>也是不同的,中间的空格区别了它们

Win98的环境变量写在了autoexec.bat

Win2000中环境变量的名在

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/SessionManager/Environment

值写在了

HKEY_CURRENT_USER/Environment

只有拥有管理员的身份才可能对其进行修改。

使用DWORD GetEnvironmentVariable(PCTSTR pszName, PTSTR pszValue, DWORD cchValue);可以确定某个环境变量是否存在以及它的值。

第一个参数为名称,第二个为存放变量值的缓存, 第三个参数为缓存的大小(用字符数来表示)

BOOL SetEnvironmentVariable(PCTSTR pszName, PCTSTR pszValue)修改与添加,删除变量,如果不存在pszName这样的变量就添加一个新的变量,如何存在就修改为pszValue。如果pszValueNULL,就删除此变量。

 

4.进程的亲缘性

进程中的线程可以在主计算机中的任何一个CPU上执行。但是一个进程的线程可能被强制在可用CPU的子集上运行,这就叫进程的亲缘性。

 

5.进程的错误模式

UINT SetErrorMode(UINT fuErrorMode);

表要加上

CreateProcess里有一个参数指定了这个,使子进程错误如何处理

进程的当前驱动器和目录

如果调用CreateFile打开一个文件(不设定路径),那么系统就在当前驱动器和目录中查找该文件。用DWORD GetCurrentDirectory(DWORD cchCurDir, PTSTR pszCurDIr)可以得到

BOOL SetCurrentDirectory(PCTSTR pszCurDir); 可以指定路径。

 

6.进程的当前目录

系统对进程的当前驱动器与目录保持跟踪,但它不跟踪每个驱动器的当前目录。这种支持是通过进程的环境字符串来提供的。例如进程有下面的两个环境变量。

=C:=C:/Utility/Bin

=D:=D:/Program Files

上面表示,驱动器C的进程的当前目录是/Utility/Bin, D的是/Program Files;

如果调用一个函数,传递一个驱动器全名,但不是当前的驱动器,那么系统就查看进程的环境块,找出与指定驱动器名相关的变量。如果存在,系统将该变量的值用作当前驱动器。如果不存在,系统将假设指定驱动器的当前目录是它的根目录。

例如进程的当前目录是C:/Utility/Bin,但调用CreateFile打开D:ReadMe.txt, 那么系统查看环境变量=D.如果=D存在,系统就从D:/Program File目录打开该ReadMe.txt文件。如果=D不存在,系统将从驱动器D的根目录来打开ReadMe.txt

 

待续...............

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章