|
In the Manifest tool node If I select Embed Manifest to No, the manifest file is created. But When I ran the application, it shows me an Assertion Failed Error. How do I resolve this error?
|
|
|
|
|
I have created two DLL .One is PracticeDLL_1 and otherone is PracticeDLL_2
PracticeDLL_1 has a function called Calc(int * ,int *)and PracticeDLL_2 has a function called Sub(int * ,int *).I am calling Calc function from
main function and which inturn calling Sub function from DLL but the function sub is not excuting .I have given the path of practiceDLL_1 in Link option in project settings and copied that dll in application folder.still i am not getting desired result. what is the probelm? can anyone help me ?
--------------------------------------------------------------
// CallingFunctionFromDLL.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include "MethodHeader.h"
int main(int argc, char* argv[])
{
int m,n;
m=100;
n=90;
//Sub(&m,&n);
char *t=Calc(&m,&n);
printf("%s \n",t);
printf("%d %d \n",m,n);
return 0;
}
----------------------------------------------
PracticeDLL_1
#include<stdio.h>
#include<conio.h>
#include "DLLHeader.h"
//#include "CodeHeader.h"
extern "C" _declspec(dllexport) char* Calc(int *no1,int *no2)
{
int sum;
char *result="successfull";
//sum = no1 + no2;
Sub(no1,no2);
//printf("%d %d",*no1,*&no2);
return result;
}
-------------------------------------------------------------
PracticeDLL_2
#include<stdio.h>
#include<conio.h>
//#include "CodeHeader.h"
extern "C" _declspec(dllexport) void Sub(int *swe,int *tur)
{
(*swe)--;
(*tur)--;
}
----------------------------------------
any help appreciated .
Thanks in advance.
|
|
|
|
|
Copy .Lib file also in Application folder and give lib name in link don't give whole path.
-@SuDhIrKuMaR@-
|
|
|
|
|
sudhir_Kumar wrote: Copy .Lib file also in Application folder and give lib name in link don't give whole path.
Why would that help ? Your lib file can be located anywhere on your disk, that doesn't make any difference.
|
|
|
|
|
I am trying to solve the problem with minimizing the complications.Nothing else you can have .lib anywhere.
-@SuDhIrKuMaR@-
|
|
|
|
|
Please read the posting guidelines before posting: put your code into the "code block" tag, otherwise it is difficult to read it.
cristi_alonso wrote: still i am not getting desired result
It would help a lot if you explain what happens exactly. Do you have a compilation error, a crash, nothing works, blue aliens invading your desk ?
cristi_alonso wrote: extern "C" _declspec(dllexport)
If the function is always exported, how will it be imported in your executable then ? You have to use dllimport in the executable. Something like this:
#ifdef DLLEXPORT1
#define DLLAPI extern "C" _declspec(dllexport)
#else
#define DLLAPI extern "C" _declspec(dllimport)
#endif
You then declare the functions this way:
DLLAPI char* Calc(int *no1,int *no2)
You then have to define DLLEXPORT1 in the first dll project options. You have to do something similar for the second dll (but use different constants, otherwise you will mix import and export).
|
|
|
|
|
There is no compilation error no crash but nothing works .I have included one header file which contain dllimport statement.
------------------Myheader.h-----------------------
<br />
<br />
extern "C" _declspec(dllimport) char * Calc(int *,int *);<br />
extern "C" _declspec(dllimport) void Sub(int *,int * );<br />
-------------------------------------------
What i am really trying to do is calling one function from a dll which inturns call another function from another dll .can anyone tell me how to do this ?now what really happens here is that calc () is getting executed but sub() is not .
any help appreciated.
Thanks in advance.
|
|
|
|
|
cristi_alonso wrote: I have included one header file which contain dllimport statement.
In general, the way to do it is to include the same heared file with the trick I gave you in my previous answer. The advantage is that you don't have to maintain two files: if you have to make a modification, it will be done in one single place.
cristi_alonso wrote: now what really happens here is that calc () is getting executed but sub() is not
How do you verify that ? Are you sure that the version of your dll in the folder of your exe is out of date and the Sub function does nothing. Recompiling your dll is not enough, you also have to copy it to the exe folder, otherwise your exe will still use the previous version. It may sound stupid, but it is a common mistake when you debug.
|
|
|
|
|
I tried by deleting the file and agian recompile but it is not working .can anyone provide me some code snippets to access any function form dll.
How can i do this with LoadLibrary and getProcessaddress method ?it will be great if anyone can provide link for this.
any help appreciated.
thanks in advance.
|
|
|
|
|
Hi,
I am displaying HTML using OnNavigateComplete2() method, inside this function I am using NavigateText()
function to dispaly HTML but at particuler point, program giving exception for some HTML text when I run the application using vista.
The function is
void CDisplayBody::NavigateText(CString pszText)
{
try
{
if (!m_bHasDocument)
{
Navigate(_T("about:blank"));
return;
}
if (GetBusy())
Stop();
IDispatch * pDisp = GetHtmlDocument();
if (!pDisp)
return;
IHTMLDocument2* pDoc;
if (SUCCEEDED(pDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc )))
{
CComBSTR bstrURL;
CComVariant varDummy;
pDoc->open(bstrURL, varDummy, varDummy, varDummy, NULL);
SAFEARRAY *pSA;
SAFEARRAYBOUND saBound = {1, 0};
pSA = SafeArrayCreate(VT_VARIANT, 1, &saBound);
VARIANT *pVar;
CComBSTR bstrHTML = pszText;
varDummy = bstrHTML;
SafeArrayAccessData(pSA, (void**)&pVar);
pVar[0] = varDummy;
SafeArrayUnaccessData(pSA);
pDoc->write(pSA);
pDoc->close();
SafeArrayUnaccessData(pSA);
SafeArrayDestroy(pSA);
pVar=NULL;
pDoc->Release();
pDoc=NULL;
}
pDisp->Release();
pDisp=NULL;
}
catch (...)
{
}
}
when control comes out the scope of if it opens a file named "atlcomcli.h" and point a statement
"HRESULT Clear() { return ::VariantClear(this); }" and program crash.
How can I resolved it?
|
|
|
|
|
I guess this problem is due to ComVariat.Try to get some tutorial how to use them.
-@SuDhIrKuMaR@-
|
|
|
|
|
Hi Friends
How to call one external .EXE file using MFC ?give any urls r something....
Thanks 'N' Advance
Nisha.S
|
|
|
|
|
use ShellExecute() or CreateProcess() functions.
|
|
|
|
|
You can use following functions
1. ShellExecute /ShellExecuteEx
2. CreateProcess
Regards,
Sandip.
|
|
|
|
|
use ShellExecute() method.
ShellExecute(handle, _T("open"), <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);
Mukesh Kumar
Software Engineer
|
|
|
|
|
::ShellExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);
may be this can help you. YOu can launch any exe file using this function and filling the structure.
|
|
|
|
|
Use ShellExecute
-@SuDhIrKuMaR@-
|
|
|
|
|
Please read the previous answers before posting. This has already been said three times before
|
|
|
|
|
Do you know toxxct?
|
|
|
|
|
Soon he will come and his wrath will be terrible
|
|
|
|
|
Cedric Moonen wrote: Soon he will come and his wrath will be terrible
Yeah Im agree with you.
|
|
|
|
|
toxxct ? who's that ?
|
|
|
|
|
Your dark side maybe ?
|
|
|
|
|
ah, it was meant darkcct ? ^^
|
|
|
|
|