Solved

Please help me with OpenDriver function

Posted on 1997-05-11
3
265 Views
Last Modified: 2010-04-06
Please describe me, how works OpenDrive function. I tried
to open the driver, such as in Delphi's help, but result was NULL :(
0
Comment
Question by:vladimir_
  • 2
3 Comments
 
LVL 3

Expert Comment

by:sperling
Comment Utility
Delphi 1, 2 or 3...

Please post the source you've written, and I'll look into it.

Regards,

Erik.
0
 

Author Comment

by:vladimir_
Comment Utility
To Sperling :

Source looks like next:
 
{ HDRVR OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName,
    LONG lParam); }
var
 lpDriverName : LPCWSTR;
 lpSectionName : LPCWSTR;
 lParam : Longint;
 ID : HDRVR;

begin
 lpDriverName :='ultrasnd.drv';
{if lpSectionName=NULL, it will automatically = Drivers16
(like Delphi's help)}
 ID :=OpenDriver(lpDriverName,lpSectionName,lParam);

{and ID will be NULL :( )


0
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
Comment Utility
As you're posting the widechar OpenDriver declaration, I assume you're using Delphi 2 or 3.

There are two errors in your code. I'm not certain, but I don't think delphi automatically converts single-byte strings to wide characters on assignment, therefore you should use StringToWideChar.

And second, as you do not set lpSectionName := nil, it would probably point to some garbage string. Local variables are not initialized automatically.

Also, the default *registry key* name is Drivers32 in Win32, and the default *ini section* is Drivers16 in Win16

var
  lpDriverName : ARRAY [0..99] OF WideChar;
  ID : HDRVR;
begin
  StringToWideChar ('ultrasnd.drv', lpDriverName, 100);
  ID :=OpenDriver(lpDriverName, nil, 0);
end;

This should work under Delphi 2 or 3

Under delphi 1, try ID := OpenDriver('ultrasnd.drv', nil, 0) instead of the above code.

Regards,

Erik.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Master Detail with TADODataset 4 96
Delphi XE10 Round Image 2 48
delphi parse string to params 3 81
Working with hours 3 31
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now