HOWTO: Access PC Bus Devices in Visual Basic for Windows

Last reviewed: July 14, 1997
Article ID: Q154819
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0

SUMMARY

This article describes how to access PC bus devices in Visual Basic for Windows. Many programs written in MS-DOS versions of BASIC used Peek, Poke, and In and Out to access the PC bus directly. This functionality is not supported in Visual Basic for Windows.

MORE INFORMATION

MS-DOS did not implement any memory protection; this meant that BASIC applications were able to write to any memory location directly, giving fast access to the hardware of the PC, including custom hardware that plugged into the expansion ports. In a multitasking environment it was clearly unacceptable for an application to write to memory owned by another application. The hardware port addresses are deemed to belong to the system. Accordingly, applications are unable to write directly to the PC bus addresses.

It is often desirable to port MS-DOS BASIC code to a Windows environment. However, programs that attempt to control custom devices will fail to port directly.

Effectively, there are two potential solutions:

  1. Use a custom Virtual Device Driver (VxD). It is likely that the manufacturers of more popular custom devices will have a VxD. However, there may be no VxD, or the VxD interface may be structured differently. Unfortunately, it is unlikely that a VxD could be accessed from Visual Basic as it is often necessary for VxD's to use Callback Functionality that is not supported in Visual Basic. It would be possible to use a C DLL to call the VxD and the DLL to be controlled from Visual Basic.

  2. Use a third-party DLL or OCX that emulates the functionality. There are a number available commercially or as shareware.

REFERENCES

For more information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q29519
   TITLE     : How to Write a Driver for a Custom Hardware Device

   ARTICLE-ID: Q87004
   TITLE     : Differences Between QuickBasic and Visual Basic Statements
 

	
	


Keywords : PrgOther vb4all vb4win kbhowto
Version : 4.0
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 14, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.