The PortIO95 VxD is designed to be dynamically loadable and will not be permit itself to be statically loaded. It is not possible to configure PortIO95 through the Windows 95 registry to always be present on the system. This means the application program has to request it at runtime. Dynamic loading (as will be shown below) is easy. On the other hand, static loading of VxD's can get very tricky. Another benefit is that each reboot ensures a clean system since PortIO95 is never present until your application runs.
The PortIO95 VxD is loaded using the conventional Windows 95 file CreateFile() function call. A special syntax on the name of the file supplied to the CreateFile() call tells Windows 95 that it is dealing with a VxD and not a regular file. The name of the VxD should be specified in the format: \\.\VXDNAME.VXD.
Here's how to do it in Visual C++ Version 4.0:
HANDLE hDevice; const PCHAR VxDName = "\\\\.\\PORTIO95.VXD"; hDevice = CreateFile(VxDName,0,0,0,CREATE_NEW,FILE_FLAG_DELETE_ON_CLOSE,0); if (hDevice == INVALID_HANDLE_VALUE) { err = GetLastError(); printf("Could Not Load VxD, error=%08lx\n", err); exit (1); } printf("VxD ->%s Now loaded \n",VxDName);
Note the odd format of the filename under C. the format \\.\VXDNAME.VXD is actually specified as \\\\.\\PORTIO95.VXD because back slashes have a special significance in C and need to be 'escaped' with more back slashes. You will also need to include one or more .h header files in your application in order to pick up the values for some of the defines in this call. (like INVALID_HANDLE_VALUE). These are supplied with your compiler. For Visual C++ 4.0 the file windows.h is sufficient. Other languages will have similar files - look up the CreateFile() call in the compilers Help menu for more information.
After a successful open, the hDevice variable will be provided in the subsequent DeviceIoControl calls that your application uses to interact with the PortIO95 VxD. This is how Windows 95 knows which VxD (there are many loaded on every Windows 95 platform) to contact.
As mentioned previously, the PortIO95 VxD loads when opened and the special syntax of the filename tells Windows 95 that is a VxD to load. Given the special format of the filename it is not possible to specify a path to the VxD within it. Windows 95 looks for the PortIO95 VxD binary by trying (in order) the following locations: