problem in passing parameter to dll function

A

andy

i am coding a dll which contains a function take a const wchar_t* as
parameter, call it form a exe, the wchar_t is passed to dll function,
but the function in dll will then call another function and pass that
wchar_t* parameter to another function, now the problem is that
functions in dll, when exported function pass parameter another
one(unexported), they both residen in the same dll, between wchar_t*
passing, the target function can't get the expected wchar_t*, but the
string len is correct, could any who know how to fix it? thanks:)
 
J

Jonathan Turkanis

andy said:
i am coding a dll which contains a function take a const wchar_t* as
parameter, call it form a exe, the wchar_t is passed to dll function,
but the function in dll will then call another function and pass that
wchar_t* parameter to another function, now the problem is that
functions in dll, when exported function pass parameter another
one(unexported), they both residen in the same dll, between wchar_t*
passing, the target function can't get the expected wchar_t*, but the
string len is correct, could any who know how to fix it? thanks:)

It's impossible to answer your question or even judge whether it is
appropriate for this group because the way you have tried to explain
it doesn't make sense.

Can you try to state your problem more clearly? Please use the
simplest example that produces the problem.

Jonathan
 
J

John Harrison

It's impossible to answer your question or even judge whether it is
appropriate for this group because the way you have tried to explain
it doesn't make sense.

Can you try to state your problem more clearly? Please use the
simplest example that produces the problem.

And post some code, you know it makes sense.

john
 
A

andy

// in .exe

typedef (*dllf)(const wchar_t* ); // This is a function pointer

dllf dllf1 = (dllf)GetProcAddress(DLLHandle,"Add");

if (dllf1 != NULL)
{

wchar_t *temp = L"DNS=sf;UID=;PWD=";
Result =dllf1( temp);


}



// in dll

extern "C" __declspec(dllexport) bool Add(const wchar_t* pODBC)

{


CADatabase *mCon = new CADatabase();
_RecordsetPtr mRs;

wchar_t temp[MAX_PATH];

if(S_OK == mCon->Connect(pODBC))
{
_bstr_t bstrQuery("insert into supplier(sup_id) values('asadf')");

mCon->ExecuteNoRs(bstrQuery);
}


return TRUE;
}

// CADatabase.cpp

_CommandPtr m_Command;

sprintf(m_ConnectionString, ConnectionString);


if (S_OK == m_Connection->Open((bstr_t)m_ConnectionString,
(bstr_t)(L""), (bstr_t)(L""), adModeUnknown))
return S_OK;



the CADatabase->Connect() never work always throws an exception, saying
that odbc driver not found.
if calling CADatabase->Connect() directly in exe. it works fine. could
any one tell me what the problem is? thanks :)
 
J

Jonathan Turkanis

the CADatabase->Connect() never work always throws an exception, saying
that odbc driver not found.
if calling CADatabase->Connect() directly in exe. it works fine. could
any one tell me what the problem is? thanks :)

Well, it doesn't help much that you've taken code from member function
bodies and placed it at top-level. Also, I don't see how the code from
the third file relates to the other code.

But since you're fetching a function pointer using GetProcAddress,
this is definitely a Windows-specific quetion. Ask in a microsoft
group.

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top