|
That was it! I had to change the C run-time library from debug multithreaded DLL to debug multithreaded.
-------------
Bibo ergo sum
|
|
|
|
|
Dear All,
I have created a MFC DLL in VS 2005. I have included this dll (dll and lib) in the VS 2003. The project compiled and running well. But, when I run the exe in another system (XP with SP3) without VS then the exe throws an error saying that "Application not correctly initialized".
I dont know the reason of this problem. Please help me...
Regards,
Bhanu
|
|
|
|
|
You will need to download and install the vc redistributable package on the target computer. You can download it from here[^]. If you have the vc2005 service pack 1 installed, you should download the version for service pack 1 (see the links at the bottom of the page).
When executing this on the target machine, it will install the C-runtime libraries and MFC libraries.
Another option would be to statically link to the C-runtime library and MFC libraries.
|
|
|
|
|
Dear Moonen,
Thank you so much for your reply.
Installing vcredist_x86.exe solves the problem, but I want my dll to be self sufficient irrespective
of the versions.
I created a MFC DLL as "Regular DLL with MFC statically linked". The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol). Please help me...
Many thanks in advance.
Bhanu
|
|
|
|
|
bhanu_8509 wrote: The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol)
What is the exact error message ?
Your MFC application also needs to statically link to the MFC.
|
|
|
|
|
The exact error message is
CSPortDlg.obj : error LNK2019: unresolved external symbol _GetDevice referenced in function "public: void __thiscall CSPortDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CSPortDlg@@QAEXXZ)
Cedric Moonen wrote: Your MFC application also needs to statically link to the MFC.
Can you please tell me how to modify the settings of my MFC application which access the DLL.
Many thanks.
Bhanu
|
|
|
|
|
Well, looking at the error message it seems something else. From where is this _GetDevice function coming from ? If it is defined in a library, did you add the library to your project ?
|
|
|
|
|
Cedric Moonen wrote: If it is defined in a library, did you add the library to your project ?
Yes the method is defined in the library. I included the library and .h file in to the application. But interestingly if I create the MFC DLL as "Regular DLL using shared MFC DLL" and include in the project then this linker error is not coming.
The above error is getting when I create the MFC DLL as "Regular DLL with MFC statically linked".
Please advice. Many thanks in advance.
Bhanu
|
|
|
|
|
It's a bit strange... Anyway, you can try to link your project statically to the MFC's but I'm not sure it will solve the problem. For VC2005, open the project properties, go to general, and for "Use of MFC" select "Use MFC in a Static Library".
|
|
|
|
|
I am sorry. Already my project setting is using "Use MFC in Static Library"
Please advice.
Many thanks.
Bhanu
|
|
|
|
|
The error message means that the problem is at linking time: the compiler is able to find the prototype of the function in one header file but when it needs to link to it, it is unable to find the function body. If this function is defined in your dll code, then you need to be absolutely sure that you added the library to your project. How did you do that ?
could you explain how you added the library to your project ?
|
|
|
|
|
Project Properties->Linker->Input->Additional Dependencies->mydll.lib
|
|
|
|
|
Hi,
I am having an INF file. I am using this INF file for uninstalling the product. After uninstallation, I want to delete all files that were installed with the product(mentioned in the .INI)
Files are getting deleted but deleting files windows box is visible. I want to suppress this dialog box from coming.
Can anyone please suggest any method for doing this?
Thanks in advance,
Abhijit
|
|
|
|
|
abhijitr wrote: Files are getting deleted...
Using what function?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
use ShFileOperation, there is flag which hide all file operation it support!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I am trying to pass an array of binary data from one function to another, but it fails. Why?
void C1:Caller()
{
BYTE *pTemplate = NULL; DWORD dwSize=0;
GetData(pTemplate, dwSize);
}
void C1:GetData(BYTE *pTemplate, DWORD &dwSize)
{
delete pTemplate;
pTemplate = NULL;
dwSize = 1024;
pTemplate = new BYTE[dwSize];
} Anyone can help me here? Thanks.
|
|
|
|
|
If you want to only pass the content of the array, then your method is fine. But as you want to allocate the a new array inside the function, you need to pass the array by reference. Think of it this way: a pointer is more or less the same as an integer containing an address. If you pass the integer value by value, a copy will be made in the function and the function will modify the copy and leave the original intact. It is the same with pointers: as long as you only want to access the content of the pointed memry, no problem. But if you want to assign a new address (like new is doing), then you have to pass it by reference:
void C1:GetData(BYTE* &pTemplate, DWORD &dwSize)
|
|
|
|
|
I knew I was missing something simple, but I do not expect it to be that simple. Thanks a lot.
|
|
|
|
|
Joe Smith IX wrote: Anyone can help me here?
Another solution is to pass the address of pTemplate to GetData() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
How To pass structure or complex data in IDispatch using invoke() method. for example I want to pass complex data or structure like below to invoke() method.
struct tag{
int i[10];
char str[40];
}sample;
Below is sample code to access method passing argument.
// Code omitted for brevity.
szMember = “On”;
dispparams.rgvarg[0].vt = VT_BOOL;
dispparams.rgvarg[0].bool = FALSE;
dispparams.rgdispidNamedArgs = &mydispid;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 1;
hresult = pdisp->GetIDsOfNames(IID_NULL, &szMember, 1,
LOCALE_USER_DEFAULT, &dispid);
hresult = pdisp->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUT,
&dispparams, NULL, NULL, NULL);
|
|
|
|
|
IIRC, a dispinterface can't take complex data like that - can't take anything that can't be represented in a VARIANT , in fact.
The usual way in which structs can be passed over COM methods is for the struct to be defined in the IDL file that defines the interface you have a pointer to. That way, COM can generate code that will marshall instances of the struct through the interface.
|
|
|
|
|
Please try with
VT_DISPATCH
by
<br />
struct tagSample: public IDispatch<br />
{<br />
int nIntArray[ 10 ];<br />
char szString[ 40 ];<br />
}smaple;<br />
Is it possible?
|
|
|
|
|
You can define a struct like that, but there's no type-safe way of accessing the data members if you pass an IDispatch pointer.
|
|
|
|
|
Thanks for the reply but my question remain unanswer.
The COM component is third party's so I donot have control on what defined in IDL or whatever technology they used.
I need to pass one argument in IDispatch's Invoke method as below . This is sample code from c# client. I want to pass structure which has byte array and string etc in c++ using IDispatch. How usually people pass structure as single argument in IDispatch's Invoke method()
public class BLOB {
/// <remarks/>
public string contentType;
public System.Byte[] binaryData;
public string ID;
public string URL;
}
|
|
|
|
|
Thomas_Mathews wrote: The COM component is third party's so I donot have control on what defined in IDL or whatever technology they used
OK, but you should have a definition of the interface somewhere - that's the point of COM - you share interface definitions.
Thomas_Mathews wrote: This is sample code from c# client
Do you have a sample of the IDispatch::Invoke call in C#?
|
|
|
|