But I have Visual Basic Professional
(Raymond Chen)
Back in 1995, I was participating in a chat room on MSN on the subject of device driver development. One of the people in the chat room asked, "Can I write a device driver in Visual Basic?"
I replied, "Windows 95 device drivers are typically written in low-level languages such as C or even assembly language."
Undaunted, the person clarified: "But I have Visual Basic Professional."
Comments
(Matt)
I have Windows XP Professional. Can I write device drivers too?
(Dan McCarty)
It would make for a pretty neat hack, though, maybe on par with writing a book without the letter e or something.
(Raymond Chen)
The question was about writing device drivers, not applications. Device drivers are written to a different API from Win32 and must observe very complex requirements. Plus you'd have to port the VB runtime library to kernel mode - the work required to do that would be greater than just writing the driver in C to begin with.
"So this is not possible with pure VB code?"
It depends on what you mean by "pure VB code". Are you referring to VB the language or VB the runtime environment?
(Rick Scott)
You probably could write one in VB6. I wrote a mouse/cursor controller in QBasic (on Win95, for an intro to computers project) using peek and poke I know that isn't a device driver (it just read from the driver's place in memory), but if you had access to memory directly, its not impossible(at least on non-NT systems), right?
(Justin Olbrantz (Quantam))
A while ago I saw an ad on a web page for an OCX that allowed VB programs to handle IRQs, I/O and other driver-type things. I don't think I could sleep for a week after seeing that
(Matthew Chaboud)
I think it would be easier for me to write a VB app that emitted the assembly for a driver than it would be for me to try and get the VB runtime environment into kernel mode.
That said, the year and change I spent working on a VB project (which integrated VB, STL, MFC, QT, and straight Win32 into one application) has still left me waking up at night. Perhaps I'm just not the right person for the job.
(GregF)
You *can* write drivers in VB (I have actually done this once) but its not really a good plan. You CAN write perfectly functional Services, though, even though Microsoft don't recommend this, it works just fine if you have taken the time to understand what a good well-behaved Service should do -- and NOT do.
It used to be perfectly normal to use little chunks of Assembler in QBASIC for hardware control. Ah, yes, the good old days.
(autist0r)
GregF, what kind of driver did you write ?! Because there is no VB compiler that generates a sys and like Raymond said, the VB API doesn't work in kernel mode... Unless you're talking about a non-kernel driver ?
(msemack)
There are toolkits that allow you to write Windows "drivers" in VB. They're user-mode drivers, though.
http://www.jungo.com/windriver_windows.html
Basically, they have a "universal" driver that runs in kernel mode. Your user-mode driver is basically a DLL which calls the kernel-mode component of WinDriver. The kernel-mode part does all of the I/O on your behalf.