acmDriverEnum problem

Posted on 1997-04-07
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
Thank you. Alex.
Question by:Madorsky
  • 2

Expert Comment

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.


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

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



Author Comment

ID: 1335226
  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}
     Result := True;

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

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

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

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

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

     acmDriverEnum(@RealCallBack, 0, 0);
{Here it hungs}
{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.}


Accepted Solution

sperling earned 50 total points
ID: 1335227
  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"




Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
error 1.1 400 Bad request idhttp delphi 18 86
Delphi Form ownership 4 87
oracle global variables 4 68
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…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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