Solved

Please help me with OpenDriver function

Posted on 1997-05-11
3
276 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
ID: 1336112
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_
ID: 1336113
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
ID: 1336114
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 151
Process Javascript errors with Delphi TWebBrowser 1 132
Working with hours 3 57
DBGrid or StringGrid ? 6 88
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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