Sunday, July 20th 2008, 2:40am UTC+1

You are not logged in.

  • Login
  • Register

1

Wednesday, May 7th 2008, 5:54am

Qt and the Win32 API

Hi,
I've been wondering, I have some example code that i'm looking at that seems to use HINSTANCE and these includes

Source code

1
2
3
4
5
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>


here's the main issue so far:
I'm having a hard time figureing out what Qt's version(if any) of HINSTACE would be. for example, the code says:

Source code

1
HINSTANCE libhandle=LoadLibrary("c:\\program files\\steinberg\\vstplugins\\muon\\cm101.dll");

now i know i can use QLibrary() to load .dll files from reading assistant. But will i be using it in the proper context if i don't find Qt's "equivalent" function?

i have "C++ GUI Programming with Qt 4" and it has a few pages on Qt and the Win32 Api, including a list of Windows functions and their Qt equivalents, but i don't see HINSTANCE here(there were only 7 different entries).

Can anyone help me out with this please?
  • Go to the top of the page

2

Wednesday, May 7th 2008, 8:40am

RE: Qt and the Win32 API

I'm not sure if I am understanding your problem but I think that you have to forget HINSTANCE. Just use QLibrary to load the library, what else do you need?

Source code

1
2
3
4
5
6
7
QLibrary myLib("c:\\program files\\steinberg\\vstplugins\\muon\\cm101.dll");

myLib.load();

if (myLib.isLoaded()) {
   // use myLib.resolve("...") to load the functions
}


Best regards,

Manuel
  • Go to the top of the page

3

Wednesday, May 7th 2008, 2:19pm

RE: Qt and the Win32 API

not exactly sure, but your example looks simple enough, thanks :)
  • Go to the top of the page

4

Wednesday, May 7th 2008, 3:44pm

RE: Qt and the Win32 API

i'm not sure if declaring this "main is such a good idea yet, since i'm used to main looking a bit different from the Qt book that i'm learning from. but the last line of code is what i'm worried about at this point. GetProcAddress() seems to be a function i would use if i were using LoadLibrary() to open the file. Qt Assistant notes a similar function, oid * QGLContext::getProcAddress ( const QString & proc ) const, but this is for OpenGL. which should i use?


so far, i have written:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <QLibrary>

#include "audioeffectx.h"

const int blocksize=512;
const float samplerate=44100.0f;

long VSTCALLBACK host(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);

void main() 
{
	/////////////////////////////////////////////////////////////////////
	//
	///					Loading a plugin
	//
	////////////////////////////////////////////////////////////////////

	//create a pointer for the plugin we're going to load
	AEffect* ptrPlug = NULL;
	bool editor;

	//find and load the DLL and get a pointer to is main function
	//this has a prototype like this: AEffect *main(audioMaterCallback audioMaster)

	QLibrary theVst("C:\\Program Files\\VstPlugins\\Crystal.dll"};

	if (theVst.isLoaded())
	{
		//DLL was loaded OK
		AEffect* (__cdecl* getNewPlugInstace) (audioMasterCallback);
		getNewPlugInstance=(AEffect*(__cdecl*)(audioMasterCallback))GetProcAddress(theVst, "main");
  • Go to the top of the page

5

Wednesday, May 7th 2008, 4:07pm

RE: Qt and the Win32 API

First of all, theVst.isLoaded() will return false unless you call theVst.load() before (only creating the object QLibrary doesn't work for me).

After that, I think you have to call...

Quoted

getNewPlugInstance = (AEffect*(__cdecl*)(audioMasterCallback)) theVst.resolve("main");


... to load the method.

Best regards,

Manuel
  • Go to the top of the page

6

Wednesday, May 7th 2008, 4:25pm

RE: Qt and the Win32 API

thanks for catching that load() function for me :) yeah, that makes more sense, i'm looking at resolve right now in Qt Assistant.

all this talk of symbols in my years of C++ yet i'm still not even sure what a symbol is...
  • Go to the top of the page

Rate this thread