Solved

Please help me with OpenDriver function

Posted on 1997-05-11
3
286 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Drag & Drop... Data from one grid to another 2 47
Twebbrowser add css to the header 3 38
DBCtrlGrid, Delphi, Scroll 7 32
Firemonkey Tcameracomponent resultion 1 20
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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