Solved

MIDI and mmsystem

Posted on 1998-04-27
10
925 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
[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
  • 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
Technology Partners: 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!

 
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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: ForceDirectory plain function 7 49
RESTRequest Parameter 4 53
Tidtcpserver listening on multiports? 1 43
Wincontrol not (correctly) drawn 15 47
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

762 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