Advertisement

problem call winapi functions from delphi5

Started by December 30, 1999 11:41 AM
5 comments, last by GameDev.net 24 years, 11 months ago
hi,

The problem (I think) is that while you include the header mmsystem.h to use the function, its body is actually located in winmm.dll, not mmsystem.dll. I believe mmsystem.dll was the 16bit version and winmm.dll is the 32bit version (which may be the cause of the "corrupt" message).

See if that helps...I had the opportunity to play with Delphi for a bit back with version 2.0? Anyway, you should be able to call any WIN32 function you want...you just need to know which .dll it resides in.

HTH,

-mordell

ps..
ok, so timegettime is also in mmsystem.dll, but I still think that is the 16bit version.

[This message has been edited by mordell (edited December 29, 1999).]

__________________________________________

Yeah, sure... we are laughing WITH you ...
Add "mmsystem" to your "uses" and you'll be able to call timeGetTime().

------------------
DavidRM
Samu Games

Advertisement
Thanks for the help.
I didnt know you could put a dll's name in the uses clause.
Any other things that may help me?
The help files don't have any thing on that or what i could find.
Looking at the units provided i see there is a mmsystem unit. So you cant put a units name in the uses clause. But there is no documentation on this unit. I dont know very much on the winapi so can you tell me what this unit is for?
The mmsystem unit should contain declarations of all the functions in the mmsystem (or winmm, I guess) DLLs. So you should be able to put
code:
uses  mmsystem;

and you should be able to call any functions from that dll. There might be a winmm unit, I don't know. Also, I don't know if in Delphi you need to put a reference in the project options to link in the winmm import library, or if that's automatic when you use the unit, but if you need to, you should get some sort of "unresolved external" error.

------------------
http://qoy.tripod.com

As the topic indicatesi'm programing in delphi, this is the source of my problem.
First I just got delphi this christmas so I havent totally learned all the features, the main area that I havent got around to looking at are the objects provided. I have the standard verion of delphi so it doesnt have a printed manual!
Ok back to my problem.
To my knowledge delphi does not provide any way of direct using the winapi via include files like C or C++. But delphi does provide a wraper around some winapi functions.
The function i'm trying to get at is timtgettime. I need to know which dll it is in and i need some one to tell me why this doesnt work.
function timeGetTime : longword; stdcall; external 'mmsystem.dll';
The error it produces when I try and compile it is :
The C:\WINDOWS\SYSTEM\MMSYSTEM.DLL file
appears to be corrupt.
Reinstall the file, and then try again.

I know a copy of timegettime is in mmsystem.dll as I used quickview on it and found it in the export table. But am I going about this in the right way? And how can i fix this problem?
I'm running win98 but it also does this to me on my other computer which is running win95.

Advertisement
About the only thing I use the MMSystem unit for is to call timeGetTime. I'm sure it has other uses.

------------------
DavidRM
Samu Games

This topic is closed to new replies.

Advertisement