OpenLibrary -- why won't this work?

Windows specific forum
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

OpenLibrary -- why won't this work?

Post 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
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

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

Post by traumatic »

You'll want to use winmm.dll instead, mmsystem.dll is 16bit only!
Good programmers don't comment their code. It was hard to write, should be hard to read.
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

It is a 16-Bit DLL, you can't load a 16-Bit DLL with a 32-Bit application
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
Last edited by netmaestro on Tue Feb 21, 2006 8:06 pm, edited 3 times in total.
BERESHEIT
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post 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.
Good programmers don't comment their code. It was hard to write, should be hard to read.
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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:
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post 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?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Straker wrote:Who'da thunk it?
lol.
@}--`--,-- A rose by any other name ..
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

That would be because midiOutGetDevCaps does not exist in that library. midiOutGetDevCapsA and midiOutGetDevCapsW exist, but not that one.
Last edited by netmaestro on Tue Feb 21, 2006 8:07 pm, edited 2 times in total.
BERESHEIT
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

No, the handle is correct. That's what you need.
Last edited by netmaestro on Tue Feb 21, 2006 8:09 pm, edited 2 times in total.
BERESHEIT
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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 :?
Post Reply