|
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#?
|
|
|
|
|
A) There is a webservice and I am writing a client in c++ to invoke that webservice using IDispatch. I have taken the sample for c++ client from codeproject and below is the link
http://www.codeproject.com/KB/COM/xysoapclient.aspx?
fid=13980&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=516139[^]
This is structure we pass in c# for calling method
[System.Xml.Serialization.XmlTypeAttribute]
public class BLOB {
/// <remarks/>
public string contentType;
[System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
public System.Byte[] binaryData;
public string ID;
public string URL;
}
B) Regarding writing a client in c# for webservice is pretty straight forward. In C# it is pass complex data in single argument.
OR
If above is complex is anyone know how to pass structure like below in IDispatch's Invoke() method. The COM Server is third party.
struct tag{
char str[100];
void *p;
char str1[300];
}
modified on Tuesday, January 20, 2009 2:25 AM
|
|
|
|
|
Firstly - you implied you had a C# client for your COM server, not for some web-service. This would appear to be incorrect...
Thomas_Mathews wrote: I am writing a client in c++ to invoke that webservice using IDispatch
Yeah...don't think that's going to work - the CP article you reference doesn't use IDispatch to call web-services, and really, IDispatch isn't for calling web services.
Thomas_Mathews wrote: This is structure we pass in c# for calling method
[System.Xml.Serialization.XmlTypeAttribute]
public class BLOB {
/// <remarks>
public string contentType;
[System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
public System.Byte[] binaryData;
public string ID;
public string URL;
}
The "[System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] " gives it away - this structure is sent to the web-service by serializing the structure contents as a chunk of XML. That implies to me that the web-service is probably using SOAP - maybe you could use something like gSOAP[^] to write your C++ client? Do you have a WSDL file that defines the web-service interface?
Thomas_Mathews wrote: If above is complex is anyone know how to pass structure like below in IDispatch's Invoke() method. The COM Server is third party.
struct tag{
char str[100];
void *p;
char str1[300];
}
Strikes me that this is a completely separate problem from the one above - the only connection is "I have a method call that I wish to serialize between a client and a remote (to some extent) server".
Now. This third-party COM server. It must define its interface somewhere. There must be something that tells you what methods it will understand on its IDispatch interface. If you don't have an IDL file, you ought to have a type library (it's usually embedded in the server somehow). Maybe you could try generating an interface to the COM server using #import [^], specifying the COM server DLL or EXE as the thing you're importing?
Also - you cannot send a struct as a parameter to an IDispatch method. Your C# web-service client manages it by converting the struct instance to an XML string which is in a format that both the client and web-service understand to mean the same thing. That means that the web-service can convert the XML string it receives into a struct instance that contains the same data that the client sent. Now, IDispatch does not have this capability. You could layer an XML serializer on top and send an XML string to the COM server as a BSTR. Would it do what you want? Probably not. But that's the thing - you have still not given sufficient detail that we can understand your problem.
|
|
|
|
|
Hi all,
I have made a dialog based application using vc2008....
I have made a worker thread inside that application and that worker thread is calling various other global functions....
But my problem is whenever the task is running and i click the dialog box anywhere on dialog box it starts displaying not responding...
I am not getting how to remove this problem....
can anybody help me in this.....
|
|
|
|