|
|
lol i agree for the speed (but can't slowdown)
i don't break the com creation mechanism : the CreateInstance in a ClassFactory does exactly the same : a new CComObject<cthing> !
|
|
|
|
|
Alexandre GRANVAUD wrote: i don't break the com creation mechanism : the CreateInstance in a ClassFactory does exactly the same : a new CComObject !
Avoiding such call you're breaking it by definition. Of course you'll see the practical implications of such a wicked act just on 'strange' servers (i.e. servers that don't "do exactly the same", such a behaviour is allowed by COM ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi,
Please, I developed an application with C + + and I need help; I am trying to test in my application that usually requires a COM + dll and I wonder how I could test that this dll is registred or no and it should display a message if this dll is not in the register or it does not exist?
thanks
|
|
|
|
|
What about calling CoGetClassObject [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i just create an instance of a class in this dll and after i do a test if it is registred or no .this are some lines of code which can explain what i need exactly:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
hRes = TContext::CreateInstanceNoAppID(CLSID_TLibraryInformation_SeeEdbUI, &piLibInfoSeeEdbUI);
if(FAILED(hRes))
{
if(hRes == REGDB_E_CLASSNOTREG)
{
strTemp.LoadString(IDS_SEEEDBUIDLL_NOT_FOUND);
TErrorTool::DisplayErrorStack(TRUE, _bstr_t(strTemp));
}
else
{
strTemp.LoadString(IDS_SEEEDBUIDLL_NOT_FOUND);
TErrorTool::DisplayErrorStack(TRUE, _bstr_t(strTemp));
}
exit(0);
}
|
|
|
|
|
You don't you trust CoGetClassObject , do you? Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
frankly, i don't try it and i would save the same structure of my code. so if you can help me with this?
|
|
|
|
|
I don't know Borland's (or CodeGear or whatever) classes so I cannot help with those.
I would keep the whole thing simple using directly COM library API , anyway, if your code is able to detect DLL 's registration, that's fine, isn't it?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Using Matt Curland's Type Library Editor, I wrote a Typelib for Nick Yakowlew's 'Charset Detector Library' . This is a standard DLL (written in Delphi as it happens) and not a COM DLL.
Up until this point I had been building ODL and thus TLB files "by hand". The benefit of this was that I could get Intellisense working in Visual Studio 6 (esp. VB6) and also be able to pass widestrings to DLLs without said strings being mangled into ANSI in the process. Once I had generated the TLB from the ODL using MIDL, I had but to register the TLB using `regtlib`, add a reference to that typelib in VB6 and cut code. And once the binary had been built, I didn't need to have the typelib around.
The typelib made by Curland's tool seems to work a little differently. It forces me to have the typelib registered for the binary to access the DLL. I exported the TLB to IDL and, well it looks a bit different to the ODL I've been writing. For one thing, there are typedefs and structs and enums. Okay, I put those in there via Curland's TLE and they need to remain. But I don't want to have to register the TLB -- I want to do things the old way.
So what do I do to the IDL below, to make it the kind of ODL I'm familiar with, yet maintain the functionality, all without needing the TLB to be registered once the binary has been produced?
<br />
[<br />
uuid(316A83D7-8BF4-490E-BDDE-75EBC332C355),<br />
version(1.0),<br />
helpstring("Charset Detector - as the name says - is a stand alone executable module for automatic charset detection of a given text.\r\n\t\r\nIt can be useful for internationalisation support in multilingual applications such as web-script editors or Unicode editors.\r\n\t\r\nGiven input buffer will be analysed to guess used encoding. The result can be used as control parameter for charset conversation procedure.\r\n\t\r\nCharset Detector can be compiled (and hopefully used) for MS Windows (as dll - dynamic link library) or Linux.\r\n\t\r\nBased on Mozilla's i18n component - http://www.mozilla.org/projects/intl/. \r\n\r\nCharset Detector is open source project and distributed under Lesser GPL.\r\nSee the GNU Lesser General Public License for more details - http://www.opensource.org/licenses/lgpl-license.php\r\n\r\nNikolaj Yakowlew \xFFFFFFA9 2006-2008 \r\nTypeLib by Bruce M. Axtens, 2008.")<br />
]<br />
library CHSDET<br />
{<br />
<br />
[<br />
dllname("CHSDET.dll"),<br />
version(1.0),<br />
helpstring("Functions in CHSDET.DLL")<br />
]<br />
module CHSDETFunctions {<br />
[entry(0x60000000), helpstring("Returns rAbout record (qv)")]<br />
void _stdcall GetAbout([in, out] rAbout* AboutRec);<br />
[entry(0x60000001), helpstring("Reset detector. Prepares for new analysis.")]<br />
void _stdcall Reset();<br />
[entry(0x60000002), helpstring("Analyse given buffer of specified length.<br />
<br />
Return value is of eHandleDataErrors, either <br />
NS_ERROR_OUT_OF_MEMORY (Unable to create internal objects) or NS_OK.<br />
<br />
Function can be called more that one time to continue guessing. Charset Detector remembers last state until Reset called.")]<br />
void _stdcall HandleData(<br />
[in] BSTR aBuf, <br />
[in] short aLen, <br />
[out, retval] short* retVal);<br />
[entry(0x60000003), helpstring("Returns either TRUE (Charset Detector is sure about text encoding.) or FALSE.<br />
<br />
NB: If input buffer is smaller then 1K, Charset Detector returns FALSE.")]<br />
void _stdcall IsDone([out, retval] short* retVal);<br />
[entry(0x60000004), helpstring("Signal data end. If Charset Detector hasn't sure result (IsDone = FALSE) the best guessed encoding will be set as result.")]<br />
void _stdcall DataEnd();<br />
[entry(0x60000005), helpstring("Returns guessed charset as rCharsetInfo record")]<br />
void _stdcall GetDetectedCharset([out, retval] rCharsetInfo* retVal);<br />
[entry(0x60000006), helpstring("Returns all supported charsets in form "0x0A Name - CodePage"")]<br />
void _stdcall GetKnownCharsets(<br />
[in, out] long* sList, <br />
[out, retval] long* retVal);<br />
[entry(0x60000007), helpstring("Return eBOMKind value matching byte order mark (if any) of input data.")]<br />
void _stdcall GetDetectedBOM([out, retval] eBOMKind* retVal);<br />
[entry(0x60000008), helpstring("Remove CodePage from consideration as a possible match")]<br />
void _stdcall DisableCharsetCP([in] long CodePage);<br />
};<br />
<br />
typedef [uuid(91694067-30AB-44A9-A210-F5602935475F)]<br />
struct tagrAbout {<br />
long lMajor;<br />
long lMinor;<br />
long lRelease;<br />
long sAbout;<br />
} rAbout;<br />
<br />
typedef [uuid(3C8B7420-D40B-458B-8DE8-9B3D28607396)]<br />
enum {<br />
BOM_Not_Found = 0,<br />
BOM_UCS4_BE = 1,<br />
BOM_UCS4_LE = 2,<br />
BOM_UCS4_2143 = 3,<br />
BOM_UCS4_3412 = 4,<br />
BOM_UTF16_BE = 5,<br />
BOM_UTF16_LE = 6,<br />
BOM_UTF8 = 7<br />
} eBOMKind;<br />
<br />
typedef [uuid(9B231DEF-93FB-440D-B06B-D760AECE09D0)]<br />
struct tagrCharsetInfo {<br />
long Name;<br />
short CodePage; <br />
long Language;<br />
} rCharsetInfo;<br />
<br />
typedef enum {<br />
NS_OK = 0,<br />
NS_ERROR_OUT_OF_MEMORY = -2147024882<br />
} eHandleDataErrors;<br />
};<br />
|
|
|
|
|
I am having a problem with safearrays. On the client side, I create a CComSafeArray and populate it with variants. Then I assign the safearray to a variant, which I pass as an in/out parameter across COM to the server. The server extracts the safearray from the variant, and attempts to extract the elements from the safearray, but fails. Any ideas why?
Here is the client function:
void CMyClass::GetData(VARIANT* pvData)
{
...
CComSafeArrayBound bound[2];
bound[0].SetCount(parms.GetSize()/2);
bound[0].SetLowerBound(0);
bound[1].SetCount(2);
bound[1].SetLowerBound(0);
CComSafeArray<variant> sa;
sa.Create(bound, 2);
LONG index[2];
for (int i = 0; i < parms.GetSize(); i+=2)
{
index[0] = i / 2;
index[1] = 0;
ATLASSERT(S_OK == sa.MultiDimSetAt(index, CComVariant(parms.GetAt(i))));
index[1] = 1;
ATLASSERT(S_OK == sa.MultiDimSetAt(index, CComVariant(parms.GetAt(i+1))));
}
pvData->vt = VT_ARRAY|VT_VARIANT;
pvData->parray = sa.Detach();
}
</variant>
The COM call looks like this:
[id(1),helpstring("...")] HRESULT SetData([in,out] VARIANT * pvntData,[out,retval] EnumResult *pVal);
And the server function(s) looks like this:
...
if (pvntData->vt == VT_ARRAY | VT_VARIANT)
{
SafeArrayCopy(pvntData->parray, &m_psaData);
SafeArrayDestroy(pvntData->parray);
}
...
m_psaData is a member variable of type SAFEARRAY *
...
long lNumRows,lNumCols;
long idxColRow[2];
SafeArrayGetUBound(m_psaData, 1, &lNumRows);
SafeArrayGetUBound(m_psaData, 2, &lNumCols);
ATLASSERT(lNumCols == 1);
VARIANT vParm1;
VARIANT vParm2;
for (int row = 0; row <= lNumRows; row++)
{
idxColRow[0] = row;
idxColRow[1] = 0;
SafeArrayGetElement(m_psaData, idxColRow, (void *)&vParm1);
idxColRow[1] = 1;
SafeArrayGetElement(m_psaData, idxColRow, (void *)&vParm2);
...
At this point, vParm1 and vParm2 are empty. Why am I not seeing the correct values?
To make matters more interesting...I DO see the expected values when I step through the debugger. But when I build a release executable, the values are empty.
Can anyone here help??
Thank you,
Tim
|
|
|
|
|
We product two COM components that our customers use. We are currently using a tool based loosly on the old NDoc tool to find differences between versions (yes its odd to use NDoc on type libraries, but it used to do a lot more). I am looking to replace that tool with one designed to report differences between two releases of a TypeLib.
Does anyone have any suggestions?
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
I use OleView.exe that comes along with Visual Studio to view type libraries and check for differences.
«_Superman_»
|
|
|
|
|
Thanks, I was hoping for more of an automated solution.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
You could write a simple program to do that.
Use the ITypeLib and ITypeInfo interfaces.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Sure, that is likely what I will do, but I would rather use an existing tool if there is one.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
Hi i am getting the error in subject line when trying to creat an object of a COM Component. I have registred the dll and tried but failed to go through.
Please provide the comment.
|
|
|
|
|
Have you called CoInitialize before trying to create the COM component?
«_Superman_»
|
|
|
|
|
Yes i have call CoInitialize(NULL) before calling CoCreatInstance().
Please provide comments ..
|
|
|
|
|
Hi,
I am using a VC6.0 COM component from .NET using late binding
(Createobject )
obj aa = createobject("dllname")
ret = aa.<function>(...)
The object was created and the function is executed , but on function return asp throws error as
Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))
Please suggest me what is the cause of this error ..
vineesh
|
|
|
|
|
I'm using IXMLHTTPRequest to retrieve a XML document to parse it in an application I'm writing for a Pocket PC. I have written a function to retrieve the XML-document as a BSTR-string. Here's my function (without error handling and such):
BSTR GetXmlFeed()
{
HRESULT hr;
HRESULT hrCoInit;
hrCoInit = CoInitializeEx(NULL,COINIT_MULTITHREADED);
MSXML2::IXMLDOMDocumentPtr pXMLDoc = NULL;
MSXML2::IXMLHTTPRequestPtr pIXMLHTTPRequest = NULL;
hr=pIXMLHTTPRequest.CreateInstance("Msxml2.XMLHTTP");
hr=pIXMLHTTPRequest->open("GET", L"http://tv4vadret.se/autoflow/export/weather?cities=tv4.vader.sverige.orter.stockholm", false);
hr=pIXMLHTTPRequest->send();
pXMLDoc=pIXMLHTTPRequest->responseXML;
BSTR bstrString;
pIXMLHTTPRequest->get_responseText(&bstrString);
return bstrString;
}
This works fantastic the first time I use the function, however if I leave the program running for a while (and sees that the xml-document I'm trying to load is updated on the webserver) and call the function again, it returns with the same value of bstrString.. Can anyone please help me?
EDIT: It somehow works now, but only after my program has been idling for 5 minutes. I would like it to be able to retrieve the information straight away!
modified on Wednesday, February 18, 2009 7:32 AM
|
|
|
|
|
We have developed an ATL/COM Addin component exe for Microsoft Excel in C++ 2005 studio and sinked all the Interface events.
The Problem is that when i try to save Excel workbook 2007 it is trapping well in "WorkbookBeforeSave "Interface.. But if i try to cancel the save with condition "* pCancel=VARIANT_TRUE" still it is allowing to save the WorkSheet.
Can anyone help me on a way out how to stop saving Excel workbook sheet?
Thanks in Advance
|
|
|
|
|
Hello All,
I am tring to port my code to 64 bit machine.
I have installed XP64 bit and successfully compiled my code with x64 Active configuration in configuration settings.
I trying to get an IDispatch for a component already registred using
COleDispatchDriver::CreateDispatch(_T("ProgramID of Component"));
This code is not returning IDispatch when the code is build with x64 Active configuration in configuration settings.
But when I build code with Active Win32 configuration it works fine.
Any body knows the reason for the same?
Thanks in Advance.
|
|
|
|
|
Hi ,
I am creating a Unit Test script in CPPUnit for a new component.
I am calling CoCreateInstance ()for a component to be created , but i am getting the error in subject line.
Please provide the comments so that i can resolve the issue.
|
|
|
|
|