Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Please help me with OpenDriver function

Posted on 1997-05-11
3
Medium Priority
?
310 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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview

886 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