• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

CreateFile for VXD's with absolute paths?

Hi Expersts!!!

 I develop a dynamic VxD , and I use:  

myCF= CreateFile("\\\\.\\VMYD.VXD",0,0,0, CREATE_NEW,FILE_FLAG_DELETE_ON_CLOSE,0);
....
 
BUT I want a NEW path to load my vxd, I want load my vxd from the C:\windows\system\  

what can I do??

any Idea??

Thanks for all!.
0
hpyam
Asked:
hpyam
  • 2
1 Solution
 
Tommy HuiCommented:
This is from the MSDN library:

Opening the VxD
You can open a static or dynamically loadable VxD by specifying the module name, filename, or registry entry identifying the VxD in a call to the CreateFile function. If the VxD exists and it supports the device IOCTL interface, the function returns a device handle that you can use in subsequent calls to the DeviceIoControl function. Otherwise, the function fails and sets the last error value to ERROR_NOT_SUPPORTED or ERROR_FILE_NOT_FOUND. You can use the GetLastError function to retrieve the error value.

When you open a VxD, you must specify a name having the following form.

\\.\VxdName
 
VxDName can be the module name of the VxD, the name of the VxD file, or the name of a registry entry that specifies the filename.

CreateFile checks for a filename extension to determine whether VxDName specifies a file. If a filename extension (such as .VXD) is present, the function looks for the file in the standard search path. In the following example, CreateFile looks for the SAMPLE.VXD file in the standard search path.

HANDLE hDevice;

hDevice = CreateFile("\\\\.\\SAMPLE.VXD", 0, 0, NULL, 0,
    FILE_FLAG_DELETE_ON_CLOSE, NULL);
 
If VxDName has no filename extension, CreateFile checks the registry to see if the name is also a value name under the KnownVxDs key in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager. If it is a value name, CreateFile uses the current value associated with the name as the full path of the VxD file. This method is useful for specifying VxDs that are not in the standard search path. In the following example, CreateFile searches the registry for the MYVXDPATH value.

hDevice = CreateFile("\\\\.\\MYVXDPATH", 0, 0, NULL, 0,
    FILE_FLAG_DELETE_ON_CLOSE, NULL);
 
If VxDName has no filename extension and is not in the registry, CreateFile assumes that the name is a VxD module name and searches the internally maintained device descriptor blocks for an already loaded VxD having the given name. In the following example, CreateFile opens the standard VxD named VWIN32.VXD.

hDevice = CreateFile("\\\\.\\VWIN32", 0, 0, NULL, 0,
    0, NULL);
 
In all cases, if CreateFile cannot find or load the VxD, it sets the last error value to ERROR_FILE_NOT_FOUND. If the function loads the VxD but the VxD does not support the device IOCTL interface, CreateFile sets the last error value to ERROR_NOT_SUPPORTED.

You can open the same VxD any number of times. CreateFile provides a unique handle each time you open a VxD, but it makes sure that no more than one copy of the VxD is loaded into memory. To ensure that the system removes the VxD from memory when you close the last instance of the VxD, use the FILE_FLAG_DELETE_ON_CLOSE value when opening dynamically loadable VxDs. Static VxDs cannot be removed from memory.

Although CreateFile has several parameters, only the lpName and fdwAttrsAndFlags parameters are useful when opening an VxD. fdwAttrsAndFlags can be zero, the FILE_FLAG_DELETE_ON_CLOSE value, or the FILE_FLAG_OVERLAPPED value. FILE_FLAG_OVERLAPPED is used for asynchronous operation and is described later in this article.

0
 
hpyamAuthor Commented:
Thanks thui.... butyou are not undertastand my question

I want load my vmyd.vxd from the path c:\windows\system\  

**  what I need write in the create file parameter which path! **

I need change the standart path! with a new path!  

Thanks Again.
0
 
hpyamAuthor Commented:
by sample
ANDLE hDevice;

    hDevice = CreateFile("\\\\.\\c:\windows\system\SAMPLE.VXD", 0, 0, NULL, 0,
        FILE_FLAG_DELETE_ON_CLOSE, NULL);

is correct the path??

what form of path I need write to load my vmyd.vxd from the c:\windows\system\  
(I copied my dynamic vxd inside the c:\windows\system\  ,...
I load my vxd dynamicly

what can I write to my path is true ??

Thanks!


0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now