|
One more clue:
This COM component accesses a webservice and invoke some methods on it. The webservice is deployed in the Tomcat Container.
(May be this is creating some problem)
|
|
|
|
|
Hi all,
Does anyonesee the following problem?
I built a COM component, and when I run my program, there's an eeror message:
Debug assertion failed!
Program: D:programs\...
File: dbgdel.cpp
Line: 47
Expression: _BLOCK_TYPE_IS_VALID(pHeap->nBlockUse)
The strange this is that if I build a dll file only (not use COM technique), that problem doesn't happen even the codes in COM and dll are exactly the same.
Thanks in advance for any help.
Nga
|
|
|
|
|
Hi,
I have created an ATL dll which has a modeless dialog box containing a WebBrowser control. My problem is that whenever I'm pressing TAB key over the WebBrowser control, the focus is not shifting to other controls or links within the web page which is getting displayed within the control.
I have implemented a hook to trap WH_GETMESSAGE message, after that I'm able to get response from the 4 arrow keys and TAB key, but that too within the dialog box.
I have to make the TAB key acting normal within the WebBrowser control that is within that dialog box.
Can anyone of you help me out? Thanks in advance.
Regards,
Ashish
|
|
|
|
|
Hi,
Does anyone know how to throw exception in COM.
Thanks in advance
|
|
|
|
|
tpndtbk wrote:
Does anyone know how to throw exception in COM.
Till i know COM
doen't support any Exception handlling.
but there other way or hack to do that
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi Alok,
You mean we can't throw exception in a COm interface function?
So what can we do if the exception happens??
|
|
|
|
|
Implement ISupportErrorInfo interface, and always try to get the HRESULT code. HRESULT tells whether the method executed successfully or some error occured.
I think this might be of your help.
|
|
|
|
|
Thanks very much.
Year, I always use HRESULT code... But I mean, how to throw an error message that the user can catch it and see it.
|
|
|
|
|
tpndtbk wrote:
I always use HRESULT code... But I mean, how to throw an error message that the user can catch it and see it.
Sorry for replying late, Actually when your class inherited From ISupportInterface.
it has a special function name
Error which help you to send special human readable warning message or failure reason to client which using your component
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi.
If, for example, you want to throw an exception from a certain method
"Test()" of a certain COM interface "IMyInterface", a possible simple solution is proposed below.
You can use either the macro "_com_raise_error(...)" or the command "throw _com_error(...)"
inside the method "Test()" for throwing an exception.
In the "client" of your "Test()" method, you can catch this exception as a "_com_error".
In the following you can find a code example.
Hoping this could help,
Manuele
Server
======
#include "comdef.h"
...
// --------------------------------------------------------------------------
STDMETHODIMP CMyInterface::Test( int p_Int )
{
HRESULT l_HR = S_OK;
// Let's suppose we want to throw an exception if the
// parameter is zero.
if ( p_Int == 0 )
{
// Create a new error info object and fill it.
ICreateErrorInfo* l_CreateErrorInfo = NULL;
GUID l_GUID = CLSID_MyInterface;
l_HR = CreateErrorInfo( &l_CreateErrorInfo );
if ( ! SUCCEEDED( l_HR ) )
{
return E_FAIL;
}
l_CreateErrorInfo->SetDescription( L"Descrizione Errore" );
l_CreateErrorInfo->SetGUID( l_GUID );
l_CreateErrorInfo->SetHelpContext( 0 );
l_CreateErrorInfo->SetHelpFile( L"HelpFile" );
l_CreateErrorInfo->SetSource( L"Source" );
IErrorInfo* l_ErrorInfo = NULL;
l_HR = l_CreateErrorInfo->QueryInterface(
IID_IErrorInfo,
( void** ) &l_ErrorInfo );
if ( ! SUCCEEDED( l_HR ) )
{
return E_FAIL;
}
l_CreateErrorInfo->Release();
// Throw the just created error info object.
// Alternatively, here you can use
// "_com_raise_error( E_FAIL, l_ErrorInfo );" as well.
throw _com_error( E_FAIL, l_ErrorInfo );
return E_FAIL;
}
return S_OK;
}
Client
======
#import "..." no_namespace
// --------------------------------------------------------------------------
int main(int argc, char* argv[])
{
HRESULT l_HR = S_OK;
IMyInterfacePtr l_MyPtr = NULL;
l_HR = CoInitialize( NULL ;
if ( ! SUCCEEDED( l_HR ) )
{
return E_FAIL;
}
l_HR = l_MyPtr.CreateInstance( __uuidof(MyInterface) );
if ( ! SUCCEEDED( l_HR ) )
{
return E_FAIL;
}
try
{
l_HR = l_MyPtr->Test( 0 );
}
catch( _com_error e )
{
// Here, you can get information made available
// by interface IErrorInfo
_bstr_t l_Description = e.Description();
DWORD l_HelpContext = e.HelpContext();
_bstr_t l_HelpFile = e.HelpFile();
_bstr_t l_Source = e.Source();
GUID l_GUID = e.GUID();
printf( "\nCOM exception caught\n\nDescription: %s, \
HelpContext: %u, HelpFile: %s, Source: %s, \
GUID: %X-%X-%X-%X",
( char* ) l_Description,
l_HelpContext,
( char* ) l_HelpFile,
( char* ) l_Source,
l_GUID.Data1,
l_GUID.Data2,
l_GUID.Data3,
l_GUID.Data4);
IErrorInfo* l_ErrorInfo = e.ErrorInfo( );
l_ErrorInfo->Release( );
}
catch( ... )
{
printf( "\nGeneric exception caught\n\n" );
}
// Release the smart pointer before calling CoUninitialize
l_MyPtr.Release( );
CoUninitialize( );
return 0;
}
|
|
|
|
|
Hi,
I would like to create a program that scans the outgoing and
incoming mails like Norton AntiVirus. From my searches I think Norton acts like SMTP+POP3 proxy. Norton does not want its users to change the server settings of their email clients to localhost to work with Norton mail scanning ( a kind of handfree approach). Can we create such a program.
So my idea is that a program that acts as a bridge between "actual mail client" and the email client and captures the incoming and outgoing mail and process those mails (virus scanning with clamav database).
Please help.........
|
|
|
|
|
Sir,
i have a datagrid containing customer order details.i want to display it in microsoft word using automation.give me some ideas or clues
|
|
|
|
|
Hi, folks,
I am writing a database access code in VC++6 using the row OLEDB interfaces, using SQLOLEDB 2.0 and connecting SQL server 2000. Running into a problem with inserting with client cursor. I found once the client cursor is on, the rowset always gets one more column than what are in the table. (which is obviously used by client cursor engine). The question is: with this extra column, how can i possibly do insert? I tried through ADO and still use SQLOLEDB on background, it is fine. I don't know how ADO solves this problem.
By the way, update and delete is fine, which is reasonable.
pIRowsetChange->DeleteRows(...) -->fine
pIRowsetChange->SetData(...) -->fine
pIRowsetChange->InsertRow(...) -->no good! error is like:
DBSTATUS_E_BADSTATUS.. DBSTATUS_E_UNAVAILABLE
Any idea?
Jason D.
Jason D.
|
|
|
|
|
What rowset options are you requesting/getting?
I've used the ATL wrappers extensively, and not have any real problems (apart from the obvious ones, like autoincrement issues)
Steve S
Developer for hire
|
|
|
|
|
Hi, Steve,
Thanks for response. I am using the following combination. Actually DBPROP_CLIENTCURSOR is not necessary, since DBPROP_IRowsetLocate acquires client cursor automatically. Any way, I have tried other combinations, like just clientcursor nothing else. As long as I turn client cursor on, inserting alway fails.
Properties[0].colid = DB_NULLID;
Properties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[0].dwPropertyID = DBPROP_IRowsetLocate;
V_VT(&Properties[0].vValue) = VT_BOOL;
V_BOOL(&Properties[0].vValue) = VARIANT_TRUE;
Properties[1].colid = DB_NULLID;
Properties[1].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[1].dwPropertyID = DBPROP_IRowsetUpdate;
V_VT(&Properties[1].vValue) = VT_BOOL;
V_BOOL(&Properties[1].vValue) = VARIANT_TRUE;
Properties[2].colid = DB_NULLID;
Properties[2].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[2].dwPropertyID = DBPROP_CANHOLDROWS;
V_VT(&Properties[2].vValue) = VT_BOOL;
V_BOOL(&Properties[2].vValue) = VARIANT_TRUE;
Properties[3].colid = DB_NULLID;
Properties[3].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[3].dwPropertyID = DBPROP_RETURNPENDINGINSERTS;
V_VT(&Properties[3].vValue) = VT_BOOL;
V_BOOL(&Properties[3].vValue) = VARIANT_TRUE;
Properties[4].colid = DB_NULLID;
Properties[4].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[4].dwPropertyID = DBPROP_IRowsetRefresh;
V_VT(&Properties[4].vValue) = VT_BOOL;
V_BOOL(&Properties[4].vValue) = VARIANT_TRUE;
Properties[5].colid = DB_NULLID;
Properties[5].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[5].dwPropertyID = DBPROP_UPDATABILITY;
V_VT(&Properties[5].vValue) = VT_I4;
V_I4(&Properties[5].vValue) = DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE | DBPROPVAL_UP_INSERT;
Properties[6].colid = DB_NULLID;
Properties[6].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[6].dwPropertyID = DBPROP_IRowsetChange;
V_VT(&Properties[6].vValue) = VT_BOOL;
V_BOOL(&Properties[6].vValue) = VARIANT_TRUE;
Properties[7].colid = DB_NULLID;
Properties[7].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[7].dwPropertyID = DBPROP_COLUMNRESTRICT;
V_VT(&Properties[7].vValue) = VT_BOOL;
V_BOOL(&Properties[7].vValue) = VARIANT_FALSE;
Properties[8].colid = DB_NULLID;
Properties[8].dwOptions = DBPROPOPTIONS_REQUIRED;
Properties[8].dwPropertyID = DBPROP_CLIENTCURSOR;
V_VT(&Properties[8].vValue) = VT_BOOL;
V_BOOL(&Properties[8].vValue) = VARIANT_TRUE;
Thanks,
Jason
|
|
|
|
|
Hi all,
I created a COM, in which I defined an enum
typedef enum
{
Time_Undefined,
CA,
ms,
s
}TimeBase;
When I import this COM into a program written in C++, everything is fine. But if I import this COM into matlab, Matlab doesn't recognise the variable type above.
Does anyone know how to solve this problem.
Thanks in advance.
|
|
|
|
|
Hi!
I designed COM+ Service with .NET. (Window2003)
I deployed My COM+ Service to ClientPC. (WinXP)
(deployed type is Application proxy)
I installed deployed proxy( .MSI file) at Client PC. (installation success)
I confirmed that proxy is running.
but, when i called proxy method, error occurred.
Msg is "access is denied".
Event log is that
"aceess is denied at DCOM", while server computer is activating, this error is occurred".
i changed my COM Properties(Permission, Security ...) according to other DCOM Access Tips.
but, it didn't work.
Please, give me an answer.
Thanks for regards.
|
|
|
|
|
I made a COM (dll) server, i hope it will work in the local
network as a DCOM , because i haven't tried it yet. So it
is three tier Database Architecture, the client programm
sends a query to the server programm ant it sends a CSV
formated data.
The first question - i tried to use ADO (_Recordset) - as
return parameter, but had error in the IDL file, i didn't
know how to avoid it, and i changed it to IUnknow, but in
the client programm i couldn't dispatch it: i did this:
In The Client:
_Recordset* pRecordset = pDatabase->GetMaterials();
ANd it ruturns 0 = WHY???
In The Server:
GetMaterials(IUnknown* pRecordset)
{
_RecordsetPtr p(__uuidof(_Recorset))
//Some Query Procedure
//And in the finish
_RecordsetPtr->QueryInterface(__uuidof(_Recordset),(void**)
&pRecordset);
return S_OK;
}
And Another Question.
Server Should be able to change the address of Database.
For example now = the addres is C:\econ.mdb;
but if the database in other place?
I tried to use GetModulFileName() - but it returned -
C:\Windows\System32\Svchost.dll.
The Main question is - how to find out where my dll
placed...
Thanks.
|
|
|
|
|
I have this strange bug witih safearrays. I was hoping you understood what is going on, so I could learn something from my mistake.
The interface I’ve designed has a method Foo
[id(7)] HRESULT Foo([in] SAFEARRAY(double)* pSA);
The function goes like this:
Foo(SAFEARRAY** pSA)
{
//destroy the incoming array
SafeArrayDestroy (pSA);
//create a new one of desired size
*pSA = SafeArrayCreateVector(VT_R8,0,10);
return S_OK;
}
In VB, I am calling the function:
Public Sub Func()
Dim arr1() as double
Dim arr2(1) as double
Obj.Foo(arr1)
MsgBox UBound (arr1)
//messagebox reports UBound is 9
Obj.Foo(arr2)
MsgBox UBound (arr2)
//messagebox reports UBound 1
End Sub
|
|
|
|
|
Change the [in] to [in,out].
The marshaller doesn't know it's supposed to send it out, otherwise.
Steve S
Developer for hire
|
|
|
|
|
Hello,
SteveS has a strong point on his reply but accidentally,
What you get is correct behavior.
the arr2 parameter in VB is a static declaration of an array with only 1 item in it, so the call to "SafeArrayDestroy(arr2)" probably fails with a meaningful error code and does not destroy the array.
On the other hand the arr1 parameter is a dynamic safe array and is allowed to be destroyed inside your C++ method.
You might also have a look at
http://www.codeproject.com/atl/udtdemo.asp
Hope This helped
Ioannis
|
|
|
|
|
Hi all,
I'm trying to write a program that can use the facilities added to XP SP2 to determine whether a given file was downloaded from the internet or not.
SP2 uses NTFS streams to attach this information to the file. Here's what I came up with:
I've used the streams.exe utility from SysInternals[^] to determine the stream name. streams.exe outputs the following for a given file:
:Zone.Identifier:$DATA 26
I can view the content of the stream like this:
more < blah.exe:Zone.Identifier
...which outputs this:
[ZoneTransfer]
ZoneId=3
According to the URLZONE definition in urlmon.h, 3 is URLZONE_INTERNET...perfect. Other files (not downloaded) simply don't have the Zone.Identifier stream.
I'm quite new to streams and I'm probably lucky to have made it thus far. Problem is, this looks like a kludge to me. I'd like to go through the "proper" interfaces to retrieve this information.
Further research on MSDN lead me here[^]. IZoneIdentifier's GetId() function seems to be exactly what I'm looking for.
I'm new to streams, but I'm even more of a newbie when it comes to interfaces, COM, ATL and all that lovely, er, stuff.
I have the February 2003 Platform SDK installed. Obviously, the corresponding urlmon.h/urlmon.idl don't contain the definitions I need. Even if I had the file(s), I'm not sure I'd be able to use midl to generate the interface, or use midl's output properly. See where I'm going with this?
I'm guessing a functioning sample for this shouldn't be terribly long...can anyone offer help, starting with "how do I get the proper declarations"? The only hit on Google re: IZoneIdentifier brings me back to MSDN...looks like this is still very new, and I can't find any more references to this...
|
|
|
|
|
You replied yourself at the beginning of the question - you're using the new facilities added in XP SP2. But you're still using the old February 2003 SDK. I think, that downloading new Platform SDK for Windows XP SP 2 would help you to find the proper definitions of interfaces and all that stuff.
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/[^]
Anyway thank you for describing how the mechanism worked, I just had some thinking about how they did it and I do forgot completelly about the streams in NTFS. Thank you.
|
|
|
|
|
> You replied yourself at the beginning of the question - you're using the new facilities added
> in XP SP2. But you're still using the old February 2003 SDK.
Right...which I why I inquired about getting updated headers.
To be honest, I only install the Platform SDK whenever it's updated on the MSDN CDs I get. I never looked into getting "live" updates...so thanks for that link.
> Anyway thank you for describing how the mechanism worked, I just had some thinking about how
> they did it and I do forgot completelly about the streams in NTFS. Thank you.
No problem--I read about how it used streams a while back, but never "really" looked any deeper into it until now. What I've found and posted about seems to be rather consistent, but I still think using streams is relying on an "undocumented dirty hack", so if the stream name changes, my code might stop working (who knows if those type of implementation details will remain the same in 2003 SP1 and beyond)...which is why I wanna try using that interface.
|
|
|
|
|
Well...I got slightly farther. Now I'm really gonna show my lack of COM experience.
This is what I currently have, slightly tweaked from some old sample. So far, this is just a simple console application:
#include <windows.h>
#include <tchar.h>
#include <urlmon.h>
int main( void )
{
HRESULT h = CoInitialize( NULL );
if( (S_OK != h) && (S_FALSE != h) )
return -1;
IZoneIdentifier* pZI = NULL;
h = CoCreateInstance(
CLSID_PersistentZoneIdentifier,
NULL,
CLSCTX_INPROC_SERVER,
IID_IZoneIdentifier,
(LPVOID*)&pZI );
if( FAILED( h ) )
return -1;
[...]
CoUninitialize();
return 0;
}
The code compiles fine, however the linker is complaining it can't find _CLSID_PersistentZoneIdentifier and _IID_IZoneIdentifier.
The updated Platform SDK's urlmon.h defines the CLSID as:
EXTERN_C const IID CLSID_PersistentZoneIdentifier;
That's the only reference I can find on my entire hard drive. The variable is declared as extern, but not defined elsewhere...likewise, _IID_IZoneIdentifier is defined in the same file as:
EXTERN_C const IID IID_IZoneIdentifier;
Where am I supposed to find those definitions?
|
|
|
|
|