|
I'm trying to run midl, however, I am encountering error after error.
Cl.exe was not located in the correct location.
when i moved it, there was no mspdb70.dll to support CL.exe.
These components were all in different folders.
Is this right? Or is my instalation of .NET completely knackered?
Is it worth moving all the tools and associated DLL's into one directory? As it's really annoying.
I've copied all the stuff in the Vc7\bin folder to the common7\tools\bin folder.
I've moved the objidl.idl file into the tools\bin directory.
It's still not building objidl.idl. I get the error "Cannot open unkwn.idl"
help!
Cata
|
|
|
|
|
Either your install is seriously f'ed up or you didn't run vcvars32.bat before trying to exec midl.
And if the paths that I have followed/have tread against the flow/there is no need for sorrow
I am coming home
Return, Crüxshadows
|
|
|
|
|
Ahhh.... Gratz
didn't run vcvars32
What does it do?
I'm relatively new to the whole COM thing, and have only just discovered all these wonderful tools in VS.
Cata
|
|
|
|
|
I've run it through the command prompt (via windows), and it says that:
vcvars32.bat is not regognised as an internal or external comman, operable program or batch file.
do i have to run this in actual dos?
Cata
|
|
|
|
|
I had 3 versions of the batch file.
2 of them had the base bath, the third one was in quotes.
the third one worked.
Weird.
Cata
|
|
|
|
|
It does what I was telling you about in the C# forum - it sets the BIN, INCLUDE, and LIB env. vars. to directories associated with VS.NET (including its common directories, the PSDK (if installed with VS.NET), and the Framework SDK). It also sets up a few more helpful things.
Setting all these in your user or system env. vars. is even better, though, because then you don't have to worry about starting a command prompt with a certain batch script like the vcvars32.bat script. This way, any programming application that uses the env. vars. for such a thing and any command prompt you start (no matter how you start it) knows where to find executables (PATH), headers (INCLUDE), and libraries (LIB). The same goes for directories and JAR packages for Java (CLASSPATH).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
There's a Visual Studio 2003 Command Prompt entry in your VS.NET start menu folder.
--
Watcha' gonna do, when Hulkamania runs wild on you!?
|
|
|
|
|
Hi all..
I want to make a component (ATL) that returns an ADO Connection..
declaration of function :
STDMETHODIMP Cobj::get_Con(_ADOConnection *pVal)
{
.
.
.
return S_OK;
}
the problem is in the IDL :
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(DCF77B2B-1F18-4753-B0E5-6A937407509C),
dual,
helpstring("Iobj Interface"),
pointer_default(unique)
]
interface Iobj : IDispatch
{
[id(1), helpstring("method GetIt")] HRESULT GetIt();
[propget, id(2), helpstring("property Con")] HRESULT Con([out, retval] _ADOConnection *pVal);
};
[
uuid(310CB985-C3C4-4244-9D75-AB3345F8E982),
version(1.0),
helpstring("RetObj 1.0 Type Library")
]
library RETOBJLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("C:\Program Files\Common Files\system\ado\msado15.dll");
[
uuid(DAACB26F-1C20-455C-A1CE-2B979040A51F),
helpstring("obj Class")
]
coclass obj
{
[default] interface Iobj;
};
};
I get an erron neer the _ADOConnection :
error MIDL2025 : syntax error : expecting a type specification near "_ADOConnection"
any help please?
|
|
|
|
|
|
Hi,
I want to pass a window handle from my MDI application to one of my active X control's function. I tried doing it , but I recieve a error in my mdi application which is as follows.
"cannot convert parameter 3 from 'struct HWND__ *' to 'struct _RemotableHandle *'".
The idl in the active X control has the following declaration.
"[id(1), helpstring("method Init")] HRESULT Init(LPTSTR lpstrCmdLine, int nCmdShow,HWND hwnd);"
Upon compiling the idl I get the following warning
"warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'hwnd' of Procedure 'Init' ( Interface 'IIWzIDE' ) ]"
Please tell me how I can pass the window handle to my active X control.
Thanks a ton in advance
belankaar
|
|
|
|
|
Hi ,
Actually HWND data type cannot be used for automation, as it is not supported.
so what you can do is simply use long data type, make "HWND hwnd" as "long hwnd" and when u recieve handle in ur activeX object typecast again into HWND
Init(LPTSTR lpstrCmdLine, int nCmdShow,long hwnd)
{
HWND wHandle =(HWND)hwnd;
// now you can use this wHandle for your purpose
-----
-----
}
Regards
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
I have found the EnumFORMATETC method for IDataObject in COM, and the C# verion, and they appear to have nothing in common. How does this:
HRESULT EnumFormatEtc(
DWORD dwDirection, //Specifies a value from the enumeration
// DATADIR
IEnumFORMATETC ** ppenumFormatetc
//Address of output variable that receives the
// IEnumFORMATETC interface pointer
);
Get turned into this:
IEnumFORMATETC OleEnumFormatEtc([in] int dwDirection);
i'm very fuzzy on this, as from what I understand, it should get turned into this:
<br />
int EnumFormatEtc(<br />
int dwDirection,<br />
out IEnumFORMATETC[] ppenumFormatetc<br />
)
If anyone could explain to me, why this is the case, I would be a very happy dude!
Cheers
Cata
|
|
|
|
|
I don't have much experience with C# but it seems that it respects the retval keyword (treating "failed" HRESULT s as exceptions).
And by the way... the ppenumFormatetc is an INTERFACE pointer, not an array.
And if the paths that I have followed/have tread against the flow/there is no need for sorrow
I am coming home
Return, Crüxshadows
|
|
|
|
|
As Stefan points out, HRESULTS are translated as exceptions in .NET. More specifically, they're translated into System.Runtime.InteropServices.COMException 's.
If you look up the IDL definition for EnumFormatEtc it'll look something like this:
HRESULT EnumFormatEtc([in] DWORD dwDirection, [out, retval] IEnumFORMATETC) All [in] parameters are treated as normal copy by value parameters. [in, out] are treated as ref parameters, and [out] are treated as out parameters in C# lingo. [out, retval] is a special kind of parameter (which must always be the last parameter by the way), which is mapped as the return type in languages which are not "C like".
The .NET framework will call the method something like this (pseudo code):
IEnumFORMATETC* EnumFormatEtc(DWORD dwDirection) {
IEnumFORMATETC* res = 0;
HRESULT hr = itf_ptr->EnumFormatEtc(dwDirection, &res);
if(FAILED(hr)) throw COMException(hr);
return res;
}
--
You're entertaining at least.
|
|
|
|
|
hi,
i have created an exe com seerver with Visual C++ 7 & WinXP SP1.
on my system ans my testing machine, my server register successfully.
But my client can't register it !
he seems he doesn't have any MFC70XX.dll on it system, thus an error appear during registration.
How can i update it system in order to add the MFC70 dll series ??
thanks.
modified 14-Jun-22 21:01pm.
|
|
|
|
|
Include a copy of the MFC 7.0 DLL with setup.
Kuphryn
|
|
|
|
|
I am exporting a function with a CString object as its parameter, as show below:
extern "C" DllExport const char* ActivatePlot(CString szPlot);
When I called this function from another DLL or module, the application crashes. From debug/call-stack I found that while returning from the function ActivatePlot() the control is in the destructor of CString object and is trying to free the memory.
When I changed the parameter type to const char* it worked fine.
Can you explain whether we can use CString object in a DllExport functions? If not why?
|
|
|
|
|
You should check MSDN. Go to www.msdn.microsoft.com And type MFC DLL export in the search field. You will find enough information on how to export functions depending on what kind of DLL are you building.
-- Sebastián.
|
|
|
|
|
Hello Kishor,
Usage of CStrings in an exported function is perfectly fine as far as I know. Your function is declared as :
extern "C" DllExport const char* ActivatePlot(CString szPlot);
This means that when your ActivatePlot() is called, MFC creates a temporary CString for szPlot to be used within the context of the ActivatePlot() function.
Now, if this input is another CString as in the following example :
CString cstr("Country road.");
ActivatePlot(cstr);
the temporary CString "szPlot" which is created and gets passed into ActivatePlot() will contain a pointer to the same string that "cstr" points to.
The reference count of the actual string ("Country road.") is incremented and "cstr" and the "szPlot" both share the same string.
It is true that when the ActivatePlot() function exits, the CString destructor is called. This is done to free the temporary CString object "szPlot".
Let's take a look at the actual source codes of the CString destructor :
CString::~CString()
// free any attached data
{
if (GetData() != _afxDataNil)
{
if (InterlockedDecrement(&GetData()->nRefs) <= 0)
FreeData(GetData());
}
}
What happens here is that the szPlot's string pointer's reference count is decremented and only if this reference count drops to zero (or negative) will the actual string be released.
In our example, if szPlot still points to the same string "Country road.", the reference count of this string in memory is decremented but the ref count will not be zero yet (cstr still holds a ref count) and no freeing is actually performed.
I believe no harm is actually done by the destructor in this sense.
Please provide more info on how you call the ActivatePlot() function as well what actually takes place in the function ActivatePlot() so that we can have a better picture of the nature of your crash.
Thanks,
Bio.
|
|
|
|
|
I desesperatly need help for passing a DISPPARAMS strucutre to IDispatch::Invoke.
Here is the calling code, in C++:
<br />
HRESULT hr;<br />
OLECHAR FAR* szMember = L"MyFunction";<br />
DISPID DispatchID;<br />
<br />
int i = 10;
<br />
DISPPARAMS DispatchParams;<br />
DispatchParams.cArgs=1;<br />
DispatchParams.rgvarg = new VARIANTARG[1];<br />
DispatchParams.rgvarg[0].vt = VT_BYREF|VT_INT;<br />
DispatchParams.rgvarg[0].pintVal = &i;<br />
DispatchParams.rgdispidNamedArgs=NULL;<br />
DispatchParams.cNamedArgs=0;<br />
<br />
CoInitialize(NULL);<br />
<br />
if (FAILED(hr = CoCreateInstance(MyCLSID, NULL, CLSCTX_SERVER, IID_IUnknown, (void FAR* FAR*)&pUnknown))) return hr;<br />
if (FAILED(hr = pUnknown->QueryInterface(IID_IDispatch, (void FAR* FAR*)&pDispatch))) return hr;<br />
if (FAILED(hr = pDispatch->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &DispatchID))) return hr;<br />
<br />
<br />
hr = pDispatch->Invoke(DispatchID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &DispatchParams, NULL, NULL, NULL);<br />
<br />
And this is the function I'm trying to call, in VB:
<br />
Public Function MyFunction(ByRef Parameter As Integer)<br />
MsgBox Str(Parameter), , "Parameter:"<br />
End Function<br />
When I run the calling code, IDispatch::Invoke returns a type mismatch error. However, if I enlarge the rgvarg field of the DispatchParams structure and write the parameter into rgvarg[1] instead of rgvarg[0] (while cArg is still 1), it does not return any error and MyFunction does show the message box, but it shows the value is 0, while it is supposed to be 10. I would add that I have no problems when using IDispatch::Invoke for calling functions that have no parameters.
I've spent hours trying to figure out what was wrong but it went nowhere. Would someone please help me ?
|
|
|
|
|
You have to use the VT_I2 or VT_I4 instead of VT_INT, because VT_INT is not OLE-compatible type at all.
Also the VB type "Integer" is the C/C++ type "short int". Therefore, you have to write
short int i = 10;
...<br />
DispatchParams.rgvarg[0].vt = VT_BYREF|VT_I2;<br />
DispatchParams.rgvarg[0].piVal = &i;
With best wishes,
Vita
|
|
|
|
|
Thank you so much, it helped a lot. Now I'm going to be careful with data types. However I have another question. I was wondering if it was possible to pass an array containing pointers to variables, these variables being either long integers or BSTR. I was thinking I could pass an array of variant, but I'm not sure about the result.
|
|
|
|
|
[quote]I was wondering if it was possible to pass an array containing pointers to variables, these variables being either long integers or BSTR. I was thinking I could pass an array of variant, but I'm not sure about the result. [/quote]
I think that this has no sense.
There is no array with reference data. Because the VARIANT with vt==VT_BYREF|VT_ARRAY|VT_?SIMPLETYPE? means the "pointer to SAFEARRAY with SIMPLETYPE members" (aka "SAFEARRAY(SIMPLETYPE)*") instead of the "SAFEARRAY with pointers to SIMPLETYPE data" (aka "SAFEARRAY(SIMPLETYPE*)").
Therefore, there is only SAFEARRAY(VARIANT) way, but the VB can use (or get) the VARIANT with VT_BYREF|VT_?SIMPLETYPE?, but cannot set such type. So I think that you can use only SAFEARRAY(VARIANT) with VT_?SIMPLETYPE? members.
With best wishes,
Vita
|
|
|
|
|
|
I want to find a LocalServer COM example not using ATL here. I have finished one but I don't know how to Register. I have tried it as below: mycom.exe -/RegServer
but my client can't create instance.so I think I have made mistaken on Registry.who can tell me something about registry?
|
|
|
|
|