Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 6:31
mveRichard MacCutchan23-Oct-11 6:31 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 5:48
appollosputnik23-Oct-11 5:48 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 6:41
appollosputnik23-Oct-11 6:41 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 6:46
mveRichard MacCutchan23-Oct-11 6:46 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 6:51
appollosputnik23-Oct-11 6:51 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 7:09
mveRichard MacCutchan23-Oct-11 7:09 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 7:23
appollosputnik23-Oct-11 7:23 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 7:31
mveRichard MacCutchan23-Oct-11 7:31 
GeneralRe: dll from win32 console. Pin
appollosputnik23-Oct-11 7:20
appollosputnik23-Oct-11 7:20 
GeneralRe: dll from win32 console. Pin
Richard MacCutchan23-Oct-11 7:25
mveRichard MacCutchan23-Oct-11 7:25 
GeneralRe: How to get a handle for a Dialog Pin
Goto_Label_23-Oct-11 8:09
Goto_Label_23-Oct-11 8:09 
GeneralRe: How to get a handle for a Dialog Pin
Richard MacCutchan23-Oct-11 9:04
mveRichard MacCutchan23-Oct-11 9:04 
GeneralRe: How to get a handle for a Dialog Pin
appollosputnik24-Oct-11 7:00
appollosputnik24-Oct-11 7:00 
QuestionC Compiler needed (64 bit)! Pin
Veeshal Beotra21-Oct-11 17:34
Veeshal Beotra21-Oct-11 17:34 
AnswerRe: C Compiler needed (64 bit)! Pin
«_Superman_»21-Oct-11 18:55
professional«_Superman_»21-Oct-11 18:55 

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.