|
3142.1
Hi everybody!
I have a problem with COM technology. Here it is:
I have two applications (let's say application A & B, c++ executable applications), and I need to run some methods of B application from A application. This is what I was succesfull at.
Here is the real problem:
I need to create some objects (dynamically) in my A application, (I was trying to inherite them from IUnknown) , and send them to application B (probably as an IUnknown), so I can use them as normal objects of the B application.
Can anybody help me with this?
Here is what I did:
I created client (A) as an client, and an B app. as an server. I have created some methods in B to see if it works (it worked), then I have created an object (X) in A app (inherited from IUnknown), and method in B app, that has an parameter LPUNKNOWN. In A app. I run this function of B's app, and I put there this X object as an parameter FunctionName((LPUNKNOWN)X);
The B app has recieved this X pointer as an IUnknown, and here comes the problem: in B app, I tried to get different interface of B object by QueryInterface function , but it returned me NULL!!! That's the problem..
Does anyone have some experience with it?
Ceno
|
|
|
|
|
Hi,
i'm using Acrobat Distiller through OLE/COM Automation as suggested in the Acrobat Distiller API Reference Guide (tech. note #5158, version 5.0). It seems to work well on Windows 2000, but i'm having COM security issues (i think) on Windows XP.
Here is a simple test case:
[1] Run the DistillerCtrl sample application provided with the Adobe Acrobat SDK v.5.0 with a user of the Administrators group. It works.
[2] Run the DistillerCtrl sample application provided with the Adobe Acrobat SDK v.5.0 with another user not part of the Administrators group. It fails.
I keep having the 0x80080005 - Server execution failed error.
DCOM configuration is set to defaults for the AcroDistX object:
Authentification Level = Default
Launch and Access Permissions = Use Default
Identity = The launching user
The client and the server both run on the same machine running Windows XP (with service pack 1).
The test only fails on Windows XP, i have no problem running it on Windows 2000. What am i missing?
HooK
|
|
|
|
|
Are you using CoInitializeSecurity, and if so, how?
Steve S
|
|
|
|
|
No i'm not using CoInitializeSecurity.
HooK
|
|
|
|
|
Hi there,
I am implementing connection points and i would like to know one thing here that is it possible to do custom marshalling with connection points.
My outgoing interface is something like this,
interface _INBDatabaseHandlerEvents
{
[helpstring("method RecieveBackupInfo")] HRESULT RecieveBackupInfo([in] BackUpInfo* bakupinfo);
}
where backupinfo is my own defined structue using multiple data types and they may not be automation compliant.
i have manually edited the coclass to
[default, source] interface _INBDatabaseHandlerEvents;
dispinterface removed and my object derives from IUnknown now.
QUESTION:
At the client side what should i do include .tlb or .h and .c for interfaces uuid.
And if provide only typelib information would it work if i have registered the proxy stub as well.
And i am just using the typelib to help the coz of not using .c and .h files from server
QUESTION:
how can i include .c file in different cpp for using cocreateinstance. It is not possible but i need the uuids for instantiating the objects.
Should i use typelib for custom interfaces with custom defined parameters it would make a difference or not.
Thanks in advance.
I'm looking forward for an urgent reply.
|
|
|
|
|
Hi,
I am working on a utility which act as an IE extension. I want to add a new 'protocol' (default IE protocols: http:, ftp:, ms-its: ..., I need to impelement my own, e.g. makecall:, goto to IE, I rem that many years ago I browse MSDN, it may called "pluggable protocol xxx", but I can't find anything in MSDN anymore.
Can any one give me a tip? many thanks.
|
|
|
|
|
I think that you need to add something like this to registry:
<br />
HKEY_CLASSES_ROOT\makecall\@ = URL: makecall Protocol<br />
HKEY_CLASSES_ROOT\makecall\URL Protocol = ""<br />
HKEY_CLASSES_ROOT\makecall\DefaultIcon\@ = C:\YourIcon.ico<br />
HKEY_CLASSES_ROOT\makecall\shell\@ = open<br />
HKEY_CLASSES_ROOT\makecall\shell\open\command\@ = "C:\YourApp.exe" "%1"<br />
i'm only pointer to myself
|
|
|
|
|
I create one remote com object - 'execel.exe' to build
execel report. but I want to know the ProcessID of this remote object. Who can help me ?
best regards!
|
|
|
|
|
just add this method
GetServerId([out] DWORD* dwProcessId);
GetCurrentProcessId() look in msdn and there you are.
|
|
|
|
|
Hi every body
I'm just a beginner in COM, and as a beginner, i'm starting with sample codes like those of MSDN.
When running this piece of code:
_Application app;
if ( !app.CreateDispatch("Excel") )
AfxMessageBox("Could not start excel);
else
{
app.SetVisible(TRUE);
AfxMessageBox("Excel is running.");
}
i got an unhandled exception:
unhandled exception in XXX.exe(MFC042D.DLL):OxC000005:access violation
when app.CreateDispatch(...) is called.
Is there any body who know what could be wrong ?
Note: I'm using VC 6.0, with Office 97, and i already check for the good excel library.
Thanks in advance
|
|
|
|
|
Shouldn't that be
CreateDispatch("Excel.Application")
Steve S
|
|
|
|
|
You're rigth. It was just a mistake when I wrote my message. It should be Excel.Application. Sorry.
My PB remains.
Thanks
|
|
|
|
|
Did u initialize COM?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Yes I did ...
if you was thinking at
<br />
BOOL CAutoProjectApp::InitInstance()<br />
{<br />
if ( !AfxOleInit())<br />
{<br />
AfxMessageBox("Could not initialize COMM dll");<br />
return FALSE;<br />
}<br />
......<br />
<br />
... no problem with this part of code.
Thanks for your answer
|
|
|
|
|
I have been thinking about this problem for days, and am unsure on the best way to proceed as I dont have enough experience. My problem is that I have a IDispatch server component sitting on a remote computer, running with DCOM, to which I need to send a very large (from 30KB upwards to about 2MB) string. Currently I have implemented this by calling my server method HRESULT ReceiveText( BSTR ) but I am concerned that this is not particularly efficient.
Alternatively I can save the text to a networked shared file which the remote server could read, but that not be a good solution for when the remote server is too remote. However the advantage of using a file is that I can zip it, which reduces the text to approx 6-8% in size.
My question is therefore what is the best way of sending/receiving text using DCOM and does anyone know of any components that I could use to zip/unzip the text before/after sending? I will be grateful for any comments and suggestions. Thank you.
|
|
|
|
|
In terms of archiving, check out CodeProject code section.
As for data sharing, one solution is TCP/IP.
Kuphryn
|
|
|
|
|
If you have to use IDispatch, then you could take advantage of the fact that a BSTR isn't necessarily a string, but is a byte counted block of words.
That would let you use zlib to compress the data in the sender, and to uncompress it in the receiver.
Steve S
|
|
|
|
|
Thanks to Kuphryn and Steve for both the replys. I intend to zip/unzip the string as suggested in order to save transmission time, and am incorporating some of the info from some of the helpful articles in CodeProject. I would also like to consider TCP/IP as a solution but that will be some steep learning so I will delay that for now. Thanks again.
|
|
|
|
|
Dear friends ,i am facing a criticalerror,pls help me out :-
My MTS component(developed using ATL and using ADO to access SQL Server) running on Win 2k behaving well normally without any error,but sometimes it abort when firing a SQL query before deafult transaction time out period ( 60 sec) and produce following error in event log file:-
"New transaction cannot enlist in the specified transaction coordinator" .
This error is occuring rarely.Pls tell what can be its reason and how to fix it .
regards
akshay
Other entries in event log file is as:-
(3016,2828)2003/09/16 15:46:00.638 H:0337 W:10158080 P:4603904 ERROR: COM
Exception in setConnection() [DbKernel.cpp(75)]
ADO ERROR @: File name=C:\ProgramFiles\......mercury_wms.udl
ADO ERROR 1: 0x8004d00a
Source : Microsoft OLE DB Provider for SQL Server
Description: New transaction cannot enlist in the specified transaction coordinator.
SqlState : (null)
NativeError: 0x0
HelpFile : (null)
HelpContext: 0
ERROR: COM Exception in executeQuery() [DbKernel.cpp(171)]
ADO ERROR 1: 0x8004d00a
Source : Microsoft OLE DB Provider for SQL Server
Description: New transaction cannot enlist in the specified transaction coordinator.
SqlState : (null)
NativeError: 0x0 HelpFile : (null)
HelpContext: 0
ERROR: Error SQL : set transaction isolation level read committed;
INSERT INTO MRC_STOCK_DATA (STOCK_ITEM_GUID, WAREHOUSE_GUID,ITEM_ID,
UNIT_ID,TOTAL_RECEIVED,TOTAL_REJECTED, TOTAL_PICK_RESERVE,TOTAL_PICKED,
TOTAL_ADJUSTED,TOTAL_RETURNED,TOTAL_DISPOSED_OFF,TOTAL_PACKED,
TOTAL_SHIPPED,ON_HAND, ON_HOLD,TOTAL_EXCESS,ON_ORDER,ON_RESERVE,
CREATED_BY, LAST_MODIFIED_BY) Select newid(),WAREHOUSE_GUID,
'{B3CE6383-EE8A-4131-8F85-6C8EB4C994B3}','{6AA23C56-7A4F-11D2-84B0-0000F80
627E2}',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 'eStore_User','eStore_User' From
Mrc_Warehouse [DbKernel.cpp(173)]
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000 ERROR: ADO
Error!- Catch Block [DalKernel.cpp(150)]
COM ERROR : 0x8004d00a
Meaning : IDispatch error #52746
Source : (null)
Description: (null)
ERROR: Generated BS error code: 0x3004009a, returned error code:0x800460ff [DalKernel.cpp(156)]
UNIT_ID,TOTAL_RECEIVED,TOTAL_REJECTED, TOTAL_PICK_RESERVE,TOTAL_PICKED,
TOTAL_ADJUSTED,TOTAL_RETURNED,TOTAL_DISPOSED_OFF,TOTAL_PACKED,
TOTAL_SHIPPED,ON_HAND, ON_HOLD,TOTAL_EXCESS,ON_ORDER,ON_RESERVE,
CREATED_BY, LAST_MODIFIED_BY) Select newid(),WAREHOUSE_GUID,
'{B3CE6383-EE8A-4131-8F85-6C8EB4C994B3}','{6AA23C56-7A4F-11D2-84B0-0000F80
627E2}',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 'eStore_User','eStore_User' From
Mrc_Warehouse [DbKernel.cpp(173)]
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000 ERROR: ADO
Error!- Catch Block [DalKernel.cpp(150)]
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000 COM ERROR
: 0x8004d00a
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000 Meaning
: IDispatch error #52746
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000 Source
: (null)
(3016,2828)2003/09/16 15:46:00.654 H:0337 W:10162176 P:4608000
Description: (null)
(3016,2828)2003/09/16 15:46:00.654 H:0338 W:10162176 P:4608000 ERROR:
Generated BS error code: 0x3004009a, returned error code: 0x800460ff
[DalKernel.cpp(156)]
|
|
|
|
|
Hi guys!
I have a problem with my ActiveX component, that i developed (with VS.NET, ATL7, C++)!
I created a ActiveX component with one property "FileName", who's a BSTR.
I have included my ActiveX component in a Visual Basic sample. The property "FileName"
is visible in the object property viewer and I can change his value! That's fine!
But when I start my Visual Basic sample, the ActiveX component will use the old
standard value of "FileName" and not the value I have changed during the design time!
Is this normal? How can I fix it?
Here is a little of my source code, the header file:
#pragma once
#include "resource.h"
#include <atlctl.h>
#include "DCIpuControl2003.h"
class ATL_NO_VTABLE CFileLogTarget :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IFileLogTarget, &IID_IFileLogTarget, &LIBID_DCIpuControl2003Lib, 1, 0>,
public IPersistStreamInitImpl<CFileLogTarget>,
public IOleControlImpl<CFileLogTarget>,
public IOleObjectImpl<CFileLogTarget>,
public IOleInPlaceActiveObjectImpl<CFileLogTarget>,
public IViewObjectExImpl<CFileLogTarget>,
public IOleInPlaceObjectWindowlessImpl<CFileLogTarget>,
public CComCoClass<CFileLogTarget, &CLSID_FileLogTarget>,
public CComControl<CFileLogTarget>
{
public:
CFileLogTarget() : m_bstrFileName(OLESTR("IpuLogFile.dat"))
{
m_bAutoSize = TRUE;
m_bResizeNatural = TRUE;
SIZEL sPix, sHiM;
sPix.cx = 32;
sPix.cy = 32;
AtlPixelToHiMetric(&sPix, &sHiM);
m_sizeExtent = sHiM;
m_sizeNatural = sHiM;
}
DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE |
OLEMISC_INVISIBLEATRUNTIME |
OLEMISC_CANTLINKINSIDE |
OLEMISC_INSIDEOUT |
OLEMISC_ACTIVATEWHENVISIBLE |
OLEMISC_SETCLIENTSITEFIRST
)
DECLARE_REGISTRY_RESOURCEID(IDR_FILELOGTARGET)
BEGIN_COM_MAP(CFileLogTarget)
COM_INTERFACE_ENTRY(IFileLogTarget)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
END_COM_MAP()
BEGIN_PROP_MAP(CFileLogTarget)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
END_PROP_MAP()
BEGIN_MSG_MAP(CFileLogTarget)
CHAIN_MSG_MAP(CComControl<CFileLogTarget>)
DEFAULT_REFLECTION_HANDLER()
END_MSG_MAP()
DECLARE_VIEW_STATUS(0)
public:
HRESULT OnDraw(ATL_DRAWINFO& di);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
USES_CONVERSION;
TCHAR pszStr[256];
_stprintf(pszStr, _T("Open / create file '%s'."), OLE2CT(m_bstrFileName));
MessageBox(pszStr);
return S_OK;
}
void FinalRelease()
{
USES_CONVERSION;
TCHAR pszStr[256];
_stprintf(pszStr, _T("Close file '%s'."), OLE2CT(m_bstrFileName));
MessageBox(pszStr);
}
public:
STDMETHOD(AddLogString)(BSTR string);
public:
STDMETHOD(get_FileName)(BSTR* pVal);
STDMETHOD(put_FileName)(BSTR newVal);
protected:
CComBSTR m_bstrFileName;
HANDLE m_hFile;
};
OBJECT_ENTRY_AUTO(__uuidof(FileLogTarget), CFileLogTarget)
And the cpp file:
#include "stdafx.h"
#include "FileLogTarget.h"
HRESULT CFileLogTarget::OnDraw(ATL_DRAWINFO& di)
{
RECT& rc = *(RECT*)di.prcBounds;
HRGN hRgnOld = NULL;
if (GetClipRgn(di.hdcDraw, hRgnOld) != 1)
hRgnOld = NULL;
bool bSelectOldRgn = false;
HRGN hRgnNew = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
if (hRgnNew != NULL)
{
bSelectOldRgn = (SelectClipRgn(di.hdcDraw, hRgnNew) != ERROR);
}
HICON hIcon = ::LoadIcon(_AtlBaseModule.GetModuleInstance(),
MAKEINTRESOURCE(IDI_FILELOGTARGET));
DrawIcon(di.hdcDraw, rc.left, rc.top, hIcon);
if (bSelectOldRgn)
SelectClipRgn(di.hdcDraw, hRgnOld);
return S_OK;
}
STDMETHODIMP CFileLogTarget::AddLogString(BSTR string)
{
return S_OK;
}
STDMETHODIMP CFileLogTarget::get_FileName(BSTR* pVal)
{
m_bstrFileName.CopyTo(pVal);
return S_OK;
}
STDMETHODIMP CFileLogTarget::put_FileName(BSTR newVal)
{
m_bstrFileName = newVal;
return S_OK;
}
Cheers,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
How can I get the information if my ActiveX component is running
in design mode (like in Visual BAsic) or in normal mode (running)?
Cheers,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
Hi there !!
Use this API GetAmbientUserMode(BOOL &bVal)
This method retrieves DISPID_AMBIENT_USERMODE. This flag indicates whether the container is in run-mode, TRUE, or design-mode, FALSE.
Regards )
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
I develop an ActiveX component with Visual Stuido .NET with ATL7.
I want to draw a icon and for that I need the instance handle of
the component. In the old way I use _Module.GetModuleInstance() ,
but that doesn't work under ATL7 in VS.NET, because the object _Module
doesn't exist!
How can I get the instance handle under ATL7 in VS.NET?
Cheers,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
the _Module thingie was splitted to several more classes - see MSDN article for CComModule Replacement Classes .
The HINSTANCE is now available as _AtlBaseModule.GetModuleInstance()
hope this helps
|
|
|
|
|
Hi,
I need to fire COM events from C# and the client to handle those events is in C++.
Following is the code snippet of the COM events and the dispinterface in C#.
[Guid("12854E47-AD44-4283-B503-1176CC827A49")]
public interface Foo1ComInterface
{
void FireRequest( string str );
}
[Guid("073D1766-7969-41fd-B794-8B65B0EADAF3")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface Foo1ComEvents
{
void FooEvent( string str );
}
[ Guid("22EFEC33-5B40-4417-AFF0-DE0C5B7C9E47")]
[ ClassInterface(ClassInterfaceType.None) ]
[ ComSourceInterfaces(typeof(Foo1ComEvents))]
public class BooHoo : Foo1ComInterface
{
.....
}
So far I have generated a tlb file using regasm and did a #import in the C++ code and am able to
call the FireRequest function as defined above from C++. But how should I handle the event
fired from the .NET side. Please help!!!
Thanks,
Abhi
|
|
|
|
|