Solved

MIDI and mmsystem

Posted on 1998-04-27
10
915 Views
Last Modified: 2012-06-27
I'm interestin about midi programmin and have made som high level mci-calls, but when I try to call functions from mmsystem.lib file it usualy gives me many error messages. Example: I put mmsystem to uses clause and definie pointer to PMidiInGetDevCapsA (var mincaps: PMidiInGetDevCapsA;) but when Imake a call  mincaps.pMid it gives me accessibility error.  
0
Comment
Question by:hanmannis
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:inter
ID: 1337369
Hi,
I am not sure but, may be you forget to initialize the memory associated with is such as
 New(mincaps); then call it safely. After you are done with is Dispose(mincaps);
Igor
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337370
Hanmannis,

Don't you've to use MinCaps^.pMid?

PS. I don't find PMidiInGetDevCapsA... Which version of Delphi are you using?

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337371
Yes Inter, I see that's a possible problem.
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1337372
PMidiInGetDevCapsA ?? pMid ??
The declaration of the function is
function midiInGetDevCapsA(DeviceID: UINT; lpCaps: PMidiInCapsA; uSize: UINT): MMRESULT; stdcall;
and the structure of PMidiInCapsA is declared as
  PMidiInCapsA = ^TMidiInCapsA;
  TMidiInCapsA = record
    wMid: Word;                  { manufacturer ID }
    wPid: Word;                  { product ID }
    vDriverVersion: MMVERSION;   { version of the driver }
    szPname: array[0..MAXPNAMELEN-1] of AnsiChar;  { product name (NULL terminated string) }
    dwSupport: DWORD;            { functionality supported by driver }
  end;

Maybe you just forgot to get memory for the pointer struct. This will work :

procedure TForm1.Button1Click(Sender: TObject);
var MyCaps : PMidiInCapsA;
    FRes   : MMRESULT;
begin
  New(MyCaps);
  FRes := midiInGetDevCapsA(0, MyCaps, SizeOf(TMidiInCapsA));
  if FRes = MMSYSERR_NOERROR then
   begin
     MessageDlg(Format('MIDI In Driver vendor: %s', [MyCaps^.szPname]), mtInformation, [mbOk], 0);
   end;
  Dispose(MyCaps);
end;

0
 
LVL 4

Expert Comment

by:d003303
ID: 1337373
Yo inter, Zif,
I havent' seen all your comments in the meantime. The question was empty when I was submitting my answer, sorry ! Yeah, you both were absolutely right.
This is real Windows multithreading ! It works perfectly in parallel, but every thread does exaclty the same thing ;-)

Cheers,
Slash/d003303
0
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.

 
LVL 5

Expert Comment

by:inter
ID: 1337374
Nice work, no problem friend.
Regards, Igor
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337375
Hi all,

You're right d003303. Besides, don't you think it would be really interesting if they could split the points? That way multiple persons could give advise and help to come to a good and well-thought answer. I read they were trying to built something like I proposed, but I haven't heard anything about it anymore... Ok, I quit, before I spoil this thread.

Regards, ZiF.



0
 
LVL 4

Expert Comment

by:d003303
ID: 1337376
Yo !
Zif, right, splitting points would be realy nice ! That would eliminate the feeling of <stealing> somebodys commented idea to implemet it in your own answer.

CU,
Slash/d003303
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337377
Yep, that's correct, because sometimes, you don't know the answer right away, but with the help of a piece of source of somebody else, you can solve it. This way, I think, both should receive some points. ZiF.
0
 

Author Comment

by:hanmannis
ID: 1337378
Thank you from your answer! I think that you were right about getting memory for the pointer struct. By the way, I'm using Delphi 3.
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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

930 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

8 Experts available now in Live!

Get 1:1 Help Now