Click here to Skip to main content
15,922,533 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dll from win32 console. Pin
appollosputnik22-Oct-11 6:09
appollosputnik22-Oct-11 6:09 
GeneralRe: dll from win32 console. Pin
Chris Losinger22-Oct-11 6:17
professionalChris Losinger22-Oct-11 6:17 
AnswerRe: dll from win32 console. Pin
Richard MacCutchan22-Oct-11 6:19
mveRichard MacCutchan22-Oct-11 6:19 
GeneralRe: dll from win32 console. Pin
appollosputnik22-Oct-11 8:27
appollosputnik22-Oct-11 8:27 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan22-Oct-11 21:37
mveRichard MacCutchan22-Oct-11 21:37 
GeneralRe: dll from win32 console. Pin
appollosputnik22-Oct-11 22:24
appollosputnik22-Oct-11 22:24 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt22-Oct-11 23:25
Stephen Hewitt22-Oct-11 23:25 
GeneralRe: dll from win32 console. Pin
appollosputnik22-Oct-11 23:50
appollosputnik22-Oct-11 23:50 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt23-Oct-11 0:03
Stephen Hewitt23-Oct-11 0:03 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 0:03
appollosputnik23-Oct-11 0:03 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt23-Oct-11 0:07
Stephen Hewitt23-Oct-11 0:07 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 0:14
appollosputnik23-Oct-11 0:14 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 0:25
appollosputnik23-Oct-11 0:25 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 0:37
appollosputnik23-Oct-11 0:37 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt23-Oct-11 0:52
Stephen Hewitt23-Oct-11 0:52 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 1:05
appollosputnik23-Oct-11 1:05 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt23-Oct-11 1:12
Stephen Hewitt23-Oct-11 1:12 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 1:13
appollosputnik23-Oct-11 1:13 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 1:47
appollosputnik23-Oct-11 1:47 
GeneralRe: dll from win32 console. Pin
Stephen Hewitt23-Oct-11 2:17
Stephen Hewitt23-Oct-11 2:17 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 1:12
appollosputnik23-Oct-11 1:12 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 1:59
mveRichard MacCutchan23-Oct-11 1:59 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 4:37
appollosputnik23-Oct-11 4:37 
Look Friends
Now I am not calling the dll from not winn32 but from another mfc exe application. Where I have a button when I press it I should load the dll and launch the mainwindow. See my two apis

void CClientRevProjDlg::OnBnClickedButton1()
{
typedef VOID (*MYPROC)(HWND);
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
HWND h = AfxGetMainWnd()->GetSafeHwnd();

// Get a handle to the DLL module.
hinstLib = LoadLibrary(L"C:\\Users\\DasmahapatraS\\Projects\\Bhagavan_Cadem\\RevolutionProj\\debug\\RevolutionProj.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "runAppli");
// Do add operation
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd) (h);
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method\n");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//And in the dll App.cpp I have an extern "C" like this....

extern "C" BOOL __declspec(dllexport) runAppli(HWND h)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// HWND h = AfxGetMainWnd()->GetSafeHwnd();
ShowWindow(h,SW_SHOW);
return true;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
With this when I press the run button from client exe, my dll mainwindow is shown but crashing and hanging for sometime. Please help me get rid of this problem someone Thanks a lot. Smile | :)
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 5:06
mveRichard MacCutchan23-Oct-11 5:06 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 5:29
appollosputnik23-Oct-11 5:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.