Index: trunk/src/kernel32/hmdevio.cpp
===================================================================
--- trunk/src/kernel32/hmdevio.cpp	(revision 7244)
+++ trunk/src/kernel32/hmdevio.cpp	(revision 7245)
@@ -1,3 +1,3 @@
-/* $Id: hmdevio.cpp,v 1.14 2001-06-23 19:43:49 sandervl Exp $ */
+/* $Id: hmdevio.cpp,v 1.15 2001-10-28 12:48:04 sandervl Exp $ */
 
 /*
@@ -130,4 +130,24 @@
 //******************************************************************************
 //******************************************************************************
+BOOL WIN32API RegisterCustomDriver(PFNDRVOPEN pfnDriverOpen, PFNDRVCLOSE pfnDriverClose, 
+                                   PFNDRVIOCTL pfnDriverIOCtl, LPCSTR lpDeviceName)
+{
+ HMDeviceDriver *driver;
+ DWORD rc;
+ 
+    driver = new HMCustomDriver(pfnDriverOpen, pfnDriverClose, pfnDriverIOCtl, lpDeviceName);
+    if(driver == NULL) {
+        DebugInt3();
+        return FALSE;
+    }
+    rc = HMDeviceRegister((LPSTR)lpDeviceName, driver);
+    if (rc != NO_ERROR) {                                /* check for errors */
+        dprintf(("KERNEL32:RegisterDevices: registering %s failed with %u.\n", lpDeviceName, rc));
+        return FALSE;
+    }
+    return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
 HMDeviceDriver::HMDeviceDriver(LPCSTR lpDeviceName, LPSTR lpOS2DevName, BOOL fCreate, 
                                WINIOCTL pDevIOCtl)
@@ -438,5 +458,5 @@
 //******************************************************************************
 HMCustomDriver::HMCustomDriver(HINSTANCE hInstance, LPCSTR lpDeviceName)
-                : HMDeviceDriver(lpDeviceName)
+                : HMDeviceDriver(lpDeviceName), hDrvDll(0)
 {
     hDrvDll = hInstance ;
@@ -447,7 +467,17 @@
 //******************************************************************************
 //******************************************************************************
+HMCustomDriver::HMCustomDriver(PFNDRVOPEN pfnDriverOpen, PFNDRVCLOSE pfnDriverClose, 
+                               PFNDRVIOCTL pfnDriverIOCtl, LPCSTR lpDeviceName)
+                : HMDeviceDriver(lpDeviceName), hDrvDll(0)
+{
+    driverOpen  = pfnDriverOpen;
+    driverClose = pfnDriverClose;
+    driverIOCtl = pfnDriverIOCtl;
+}
+//******************************************************************************
+//******************************************************************************
 HMCustomDriver::~HMCustomDriver()
 {
-   FreeLibrary(hDrvDll);
+   if(hDrvDll) FreeLibrary(hDrvDll);
 }
 //******************************************************************************
Index: trunk/src/kernel32/hmdevio.h
===================================================================
--- trunk/src/kernel32/hmdevio.h	(revision 7244)
+++ trunk/src/kernel32/hmdevio.h	(revision 7245)
@@ -1,3 +1,3 @@
-/* $Id: hmdevio.h,v 1.3 2001-06-04 21:18:40 sandervl Exp $ */
+/* $Id: hmdevio.h,v 1.4 2001-10-28 12:48:04 sandervl Exp $ */
 
 #ifndef __DEVIO_H__
@@ -11,4 +11,5 @@
 #include "HMDevice.h"
 #include "HMObjects.h"
+#include <custombuild.h>
 
 #ifndef _OS2WIN_H
@@ -103,11 +104,4 @@
               LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
 
-typedef HANDLE (* WIN32API DrvOpen)(DWORD dwAccess, DWORD dwShare);
-typedef void   (* WIN32API DrvClose)(HANDLE hDevice);
-typedef BOOL   (* WIN32API DrvIOCtl)(HANDLE hDevice, DWORD dwIoControlCode,
-                       LPVOID lpInBuffer, DWORD nInBufferSize,
-                       LPVOID lpOutBuffer, DWORD nOutBufferSize,
-                       LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
-
 typedef struct {
     char     szWin32Name[32];
@@ -152,4 +146,7 @@
 public:
   HMCustomDriver(HINSTANCE hInstance, LPCSTR lpDeviceName);
+  HMCustomDriver(PFNDRVOPEN pfnDriverOpen, PFNDRVCLOSE pfnDriverClose, 
+                 PFNDRVIOCTL pfnDriverIOCtl, LPCSTR lpDeviceName);
+
   virtual ~HMCustomDriver();
 
@@ -168,7 +165,7 @@
                                      LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
 private:
-  DrvOpen  driverOpen;
-  DrvClose driverClose;
-  DrvIOCtl driverIOCtl;
+  PFNDRVOPEN  driverOpen;
+  PFNDRVCLOSE driverClose;
+  PFNDRVIOCTL driverIOCtl;
   HINSTANCE hDrvDll;
 };
