Solved

acmDriverEnum problem

Posted on 1997-04-07
3
373 Views
Last Modified: 2010-04-03
I'm trying to link msacm32.dll to my Delphi program.
Everything goes well until I try to call acmDriverEnum -
I receive different Error messages, sometimes Windows symply
hungs and so on. I think the problem is how to correctly
declare the Callback function and pass it's address to
acmDriverEnum. If somebody has a piece of working Delphi
code which calls acmDriverEnum - would you like to send it
here?
Thank you. Alex.
0
Comment
Question by:Madorsky
  • 2
3 Comments
 
LVL 3

Expert Comment

by:sperling
ID: 1335225
As you haven't posted the failing source, it's kind of hard to tell what the problem is.

But, a common mistake is to forget the stdcall directive. Almost all callback functions should be declared using this.


E.g.

procedure ThisIsACallback(AParam, AnotherParam : DWORD); stdcall;
begin
end;


If this isn't the problem, leave me a comment along with some source code, and I'll have a look at it.


Regards,

Erik.
0
 

Author Comment

by:Madorsky
ID: 1335226
var
  acmGetVersion: function : DWORD;
  acmDriverEnum: function(fnCallback: Pointer; dwInstance,                           fdwEnum: DWORD) : DWORD ;


function RealCallback
         (
              hadid: DWORD;
              dwInstance, fdwSupport: DWORD
         ):Boolean; stdcall;
{I've tried also cdecl, pascal and so on - without success}
begin
     Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var lhDll, sfHandle: DWORD;
begin

     lhDll := LoadLibrary ('msacm32.dll');
     if lhDll < 32 then
     begin
          MessageDlg('No DLL', mtError, [mbOk], 0);
     end;

     @acmGetVersion := GetProcAddress(lhDll, 'acmGetVersion');
     if @acmGetVersion = nil then
     begin
          MessageDlg('No acmGetVersion', mtError, [mbOk], 0);
     end;

     @acmDriverEnum := GetProcAddress(lhDll, 'acmDriverEnum');
     if @acmDriverEnum = nil then
     begin
          MessageDlg('No acmDriverEnum', mtError, [mbOk], 0);
     end;

     Label1.Caption := IntToHex(acmGetVersion, 8);
{The result is $04000000 - looks good}

     acmDriverEnum(@RealCallBack, 0, 0);
{Here it hungs}
end;
{I've also tried to create the procedural type and variable of
that type, and pass that var to acmDriverEnum by reference -
result is the same.}

0
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1335227
var
  acmGetVersion: function : DWORD;
  acmDriverEnum: function(fnCallback: Pointer; dwInstance, fdwEnum: DWORD) : DWORD ;


Here's the error.

Append a stdcall to these lines.

  acmGetVersion: function : DWORD; stdcall;
  acmDriverEnum: function(fnCallback: Pointer; dwInstance, fdwEnum: DWORD) : DWORD ; stdcall;

acmGetVersion works regardless of calling convention, because it doesn't take any parameters, and return value is passed back the same way in all calling conventions. acmDriverEnum expects parameters to be passed using "stdcall", while your declaration passes parameters using the default "register"


Regards

Erik.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using FastMM4... should I enable MMX option? 9 76
ddeman not working in activex 3 93
How to renew a Delphi rad-studio licence? 5 49
tidtcpserver connection lost handle 2 71
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

16 Experts available now in Live!

Get 1:1 Help Now