Hi! I've been looking through online materials on this matter with no concrete definitions of what I can do with this. I am trying to export some of the functions from my class residing in my executable. I have tried every which way I can imagine but the variables I am passing are shifting when I have entered the exported function.

with lpszDllEffect = A and lpszXmlEffect = B;

HRESULT G_A_U_D::NewModuleEffect( LPCWSTR lpszDllEffect, LPCWSTR lpszXmlEffect )
{
	HRESULT hr = S_OK;;

	HINSTANCE hdll = NULL;
	typedef HRESULT (*pNewModuleEffect)( LPCWSTR, LPCWSTR );
	pNewModuleEffect NewModuleEffect;
	
	hdll = GetModuleHandle(L"C:/Projects/DUALITY/X64/Debug/DUALITY.EXE");
	
	NewModuleEffect = (pNewModuleEffect)
		(GetProcAddress( hdll, "NewModuleEffect" ));
	
	hr = NewModuleEffect( lpszDllEffect, lpszXmlEffect );

	if(FAILED(hr))
		return hr;

	return hr;
}

results in here

extern "C" HRESULT DMA::NewModuleStudio( LPCWSTR lpszDllStudio, LPCWSTR lpszXmlStudio )
{
	HRESULT hr = S_OK;;

	HINSTANCE hdll = NULL;
	typedef void (*pLoadStudio)(ICLIENT**);
	pLoadStudio LoadStudio;
	
	wstring Plug = DIR_ROOT + DIR_DLL + wstring(lpszDllStudio);
	hdll = LoadLibraryEx(Plug.c_str(), NULL, 0 );
	LoadStudio = (pLoadStudio)(GetProcAddress( hdll, "GetNewClient" ));
	LoadStudio(&Client);

	ISerialize* LoadClient;
	hr = Client->QueryInterface(IID_ISerialize, (void**)&LoadClient);
	if(FAILED(hr))
		return hr;

	LoadClient->Deserialize(lpszXmlStudio);

	return hr;
}

are lpszDllEffect = B and lpszXmlEffect = unknown ptr;

I have tried both def file and __declspec( dllexport ) and also have tried changing my types to UINT with the same result. Is this just not possible? Looking at MSDN it does not actually say either way and it general sticks with "to export a class and ALL of its members..." I don't wan't to export all of the members but I don't want to start mucking around with STATIC members.

My present alternative is to maintain the flow through the abstract interface acquired when loading the DLL. This would just mean timing the events and sequencing the passing of variables through each call.

First thread, hi! o-o

Recommended Answers

All 2 Replies

Export members selectively from your dll:

class my_class
{
    public:
        void foo() ; // not exported
        __declspec(dllexport) void bar() ; // exported
};

void my_class::foo() {}

__declspec(dllexport) void my_class::bar() {}

And import them selectively in places where you want to use it:

class my_class
{
    public:
        void foo() ; // not imported
        __declspec(dllimport) void bar() ; // imported
};

void my_class::foo() {}

see the section 'Selective Member Import/Export' here:
http://msdn.microsoft.com/en-us/library/81h27t8c%28VS.80%29.aspx

I was going to post an example of my having done this also as I had stated "I have tried both def file and __declspec( dllexport ) and also have tried changing my types to UINT with the same result!" The data shifted in all cases??? This is alright, I'm thinking on something of a Lazy Natural Parser for resource management. :P Might as well this exporting stuff seems a little to thread bare and readily interupted by external events... o~o

Thanks Anyway,
BekaD:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.