Page 1 of 2

OpenLibrary -- why won't this work?

Posted: Wed Jan 25, 2006 9:08 pm
by jonljacobi
Teststring.s = "c:\windows\system\mmsystem.dll"
hlib.l = OpenLibrary(#PB_Any, Teststring.s)
Debug(FileSize(Teststring.s))
Debug(hlib.l)

FileSize sees it, yet I can't seem to get a handle. LoadLibrary_ doesn't return one either and I'm clueless as to why (no wisecracks please... ;-)). This is rather important to me as I need to use this dll and several others.

Cheers, JJ

Re: OpenLibrary -- why won't this work?

Posted: Wed Jan 25, 2006 9:26 pm
by traumatic
You'll want to use winmm.dll instead, mmsystem.dll is 16bit only!

Posted: Wed Jan 25, 2006 9:29 pm
by jonljacobi
I'll be changing a whole lot of stuff, but not until it's up and running as it was... ;-) 30,000 lines is a lot to debug as it is.

And that ones doesn't return a handle either...

Jon

Posted: Wed Jan 25, 2006 9:30 pm
by ts-soft
It is a 16-Bit DLL, you can't load a 16-Bit DLL with a 32-Bit application

Posted: Wed Jan 25, 2006 9:36 pm
by netmaestro
Check your path. I often don't specify a path for a windows dll as it will be found if it exists without expressing the full path.

Posted: Wed Jan 25, 2006 9:37 pm
by traumatic
jonljacobi wrote:And that ones doesn't return a handle either...
Which one? What is it you don't want to change? You can't use mmsystem.dll,
no one can, just use winmm.dll, it's "the same" anyway.

Posted: Wed Jan 25, 2006 9:48 pm
by jonljacobi
Well, the path was the thing screwing up the winmm.dll load since I had it set to the 16-bit system folder. All's well now. It was a 16-bit program, 11 years old as are my programming skills. I guess I'll have recreate the resource DLL as 32-bit as well.

Thanks for all the help guys.

Cheers, Jon :idea:

Posted: Wed Jan 25, 2006 11:41 pm
by Straker
ts-soft wrote:It is a 16-Bit DLL, you can't load a 16-Bit DLL with a 32-Bit application
Who'da thunk it?

Posted: Thu Jan 26, 2006 12:24 am
by ts-soft
It's a limitation of "flat memory"-Modell by MS
Only with Ole-Servers (16-Bit Exe) can you use a 16-Bit DLL

Posted: Thu Jan 26, 2006 1:58 am
by Dare2
Straker wrote:Who'da thunk it?
lol.

Posted: Thu Jan 26, 2006 4:05 am
by jonljacobi
Thunks a lot...

While we're at it.

*lpGetNativeSystemInfo = GetProcAddress_(GetModuleHandle_("kernel32.dll"), "GetNativeSystemInfo")
Debug(*lpGetNativeSystemInfo)
hlibWinmm.l = OpenLibrary(#PB_Any, "c:\windows\system32\winmm.dll")
Debug(hlibWinmm.l)
*lpmidiOutGetDevCaps = GetProcAddress_(GetModuleHandle_("c:\windows\system32\winmm.dll"), "midiOutGetDevCaps")
Debug(*lpmidiOutGetDevCaps)

Why does the first work, and the second not work? We'll start with I'm stupid and work from there...


Cheers, Jon

Posted: Thu Jan 26, 2006 4:18 am
by netmaestro
That would be because midiOutGetDevCaps does not exist in that library. midiOutGetDevCapsA and midiOutGetDevCapsW exist, but not that one.

Posted: Thu Jan 26, 2006 5:05 am
by jonljacobi
I was using IsFunction with the same result--zero, which is why I switched to GetProcAddress in the first place. I thought maybe IsFunction wanted a plain number instead of a handle. Replace GetProcAddress with IsFunction and the problem remains.

Cheers, Jon

Posted: Thu Jan 26, 2006 5:46 am
by netmaestro
No, the handle is correct. That's what you need.

Posted: Thu Jan 26, 2006 5:59 am
by jonljacobi
Well, it seems you're correct, but every shred of API info (XP SP2 SDK help, Win32 API reference help) I have mentions nothing about this. Where did you find those functions?? :?:

By the way, PB already has midiOutGetDevCaps_ so it appears I don't even need to go through all this...

These forums are a great help, but I wish I didn't have to bother everyone while I'm getting up to speed. Has anyone written a users guide or is there a central repository for demos and examples around somewhere?

Thanks.

Jon :?