|
Heh, as it reads in the question itself (First Chance exception....), only unless you turn off automatic handling of that exception, it just does a print to the debug window....
Ah well...perhaps I didn't build the object right...
|
|
|
|
|
"First chance exception in ... : Microsoft C++ Exception" means a C++ exception is thrown but not catch. Try to wrap up your method call in a try / catch statement, and catch a _com_error exception. Take a look at the error code.
|
|
|
|
|
Its just an access violation in Kernel32 once the raw_ function loses scope, which means it could be anything, so I think I'll just drop it. Ah well, I've got to get back to DOS programming now....
|
|
|
|
|
I can create MULTIPLE internet shortcuts by the following code
CComQIPtr<IUniformResourceLocator, &IID_IUniformResourceLocator> m_spURL;
CComQIPtr<IPersistFile, &IID_IPersistFile> m_spPF;
CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, IID_IUniformResourceLocator, (LPVOID*) &m_spURL);
if (m_spURL == NULL) return E_FAIL;
m_spPF = m_spURL;
if (m_spPF == NULL) return E_FAIL;
m_spURL->SetURL(strUrl1, 0);
m_spPF->Save(strFile1.AllocSysString(), TRUE);
m_spURL->SetURL(strUrl2, 0);
m_spPF->Save(strFile1.AllocSysString(), TRUE);
m_spURL->SetURL(strUrl3, 0);
m_spPF->Save(strFile3.AllocSysString(), TRUE);
But trying to load more than one shortcuts will fail
hr = m_spPF->Load(strFilename1.AllocSysString(), STGM_READ);
LPSTR lpTemp1 = NULL;
hres = m_spURL->GetURL(&lpTemp1);
if (SUCCEEDED(hres))
{
IMalloc* pMalloc;
hres = SHGetMalloc(&pMalloc);
if (SUCCEEDED(hres))
{
pMalloc->Free(lpTemp);
pMalloc->Release();
}
}
hr = m_spPF->Load(strFilename2.AllocSysString(), STGM_READ);
DWORD E = GetLastError();
Did I forget release something? is there something like "close" I have to call? Of course, I can release both interface
and create a new one, but why I can save multiple urls? also, Is createinstance consider an expensve function call?
Thanks for help!
Shawn
|
|
|
|
|
Hi All,
I'm working on a small project which converts PowerPoint documents to SWF. The convertor contains of two parts, the PPT extractor and the SWF composer. The extractor basically traverses the presentation's object model and extracts information that it understands and stores them. The problem I'm getting is when accessing certain objects (such as _Presentation->_Slide->Shape->Vertices or _Presentation->_Slide->Shape->Adjustments) using the raw interface I got E_ACCESSDENIED return code. Here's an excerpt of the code:
// Env: Windows XP, Office 2000
#import "MSO9.DLL" auto_rename
#import "VBE6EXT.OLB" auto_rename
#import "MSPPT9.OLB" auto_rename
using namespace PowerPoint;
...
PowerPoint::ShapePtr aShape = ...;
VARIANT aVertices;
HRESULT hRes = aShape->get_Vertices(&aVertices);
And now hRes is E_ACCESSDENIED. This happens to some other objects too. I've read some MSDN articles talking about Office automation is unsupported etc. So my questions are, how should I deal with these Access Denied errors? Does this look like a setting problem, or is it VC++? Will this become better if I use VB? The reason I use VC++ is I want to make the extract and the composer one single program. I'm not fluent in VB but if I make sure this could be solved in VB then I'd definitely like to try it. Any suggestion is appreciated!
Thanx, and Best,
Darrel
|
|
|
|
|
I have a com dll written in C++ which is used in asp applications. The dll contains only one com object. There are static (global to the process) data objects within this dll. Obviously, I only want to initialize these static objects when the dll is first loaded.
However, IIS seems to be reloading my dll everytime the com object is created and used in an asp page.
|
|
|
|
|
The proper way to do it is to make your server a service, if your objects need to have some context setup once per session. The answer to your question is to return allways S_FALSE from DllCanUnloadNow. In case you are using ATL you can achieve this by having a CAtlModule::Lock call without CAtlModule::Unlock pair.
|
|
|
|
|
Thanks for the help. I don't want to make my com dll a service right now. I tried to return S_FALSE in DllCanUnloadNow and also called CAtlModule::Lock without calling Unlock. Doesn't seem to work.
I remember when building a com dll in VB6, you can specify a project setting called "retained in memory" which will do exactly what I want. Is there an equivalent of this feature in VC++?
|
|
|
|
|
Returning S_FALSE from DllCanUnloadNow should leave the dll loaded. I don't know VB, so I cannot tell exactly what that property does, but I suppose it will do the same thing ( return false from can unload now). Did you check if it's the same process ? ( maybe the process will exit, so normally all the dlls will be unloaded).
|
|
|
|
|
I am new in COM programming so I have a question that is maybe very simple for you, but I do not know the answer.
My client and server applications are running on two different PC's, so I have a remote connection. I want to implement the client in such a way that the user can change the name of the PC where the server is running. I want this to be flexible for future changes if the server has to be installed on another PC.
Can someone explain me how to solve this? Do you have an URL where I can find an example with the solution for my problem.
Thanks.
MauriceMG
|
|
|
|
|
See the answer to "DCOM & Dual Lan" below [^]
|
|
|
|
|
My problem is solved now.
Thanks for your reaction.
MauriceMH
|
|
|
|
|
Does anyone know if there is a function I can call to determine if I an inside a STA or a MTA (apart from calling CoInitializeEx and checking for RPC_E_CHANGED_MODE).
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Looking for "DebugCoQueryApartmentID" word in MSDN's Bugslayer 1998[^].
With best wishes,
Vita
|
|
|
|
|
|
HI all,
I need to pass safearray of user defined data type( my structure ConInfoStruct) from the COM server dll to MFC client. I declared my structure in IDL file like this:
typedef [uuid(F5C2F02A-09D3-4fca-B5A9-5413009F6365)] struct tagConInfoStruct
{
ULONG m_ipAddress;
USHORT m_appType;
ULONG m_appID;
}ConInfoStruct;
when i build this code, MIDL doesnt generate GUID for the above structure. So Retrieving IRecordInfo pointer using UUID_ConInfoStruct from the client failed as UUID_ConInfoStruct is an undeclared identifier. Has anyone faced this problem before. Please let me know a solution for this problem.
thanks
bharani
|
|
|
|
|
Remove the "tag" part from "tagConInfoStruct"! Also you should use OLE Automation types if you want use this structure in OLE client. Both ULONG and USHORT are incompatible with OLE. Use signed long and short types.
typedef [uuid(F5C2F02A-09D3-4fca-B5A9-5413009F6365)]
struct ConInfoStruct
{
LONG m_ipAddress;
SHORT m_appType;
LONG m_appID;
}ConInfoStruct;
With best wishes,
Vita
|
|
|
|
|
Anyone knows what message ids com use for marshaling calls??
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
In a MS Word automating program, I want to get a ShapeRange from a Shapes object, which need a SafeArray parameter. I wrote the following code:
------------------------------------------
COleSafeArray sa;
DWORD bounds=1;
sa.Create(VT_VARIANT,1,&bounds);
COleVariant v_ind((long)1,VT_I4);
long ind=0;
sa.PutElement(&ind,&v_ind);
//sa.Detach();
CShapes shapes(doc.GetShapes());
CShapeRange sr(shapes.Range(sa));
-------------------------------------------
It just throws an exception saying that the parameter has an invalid value. If I Detach the array before passing it to the Range method, the array becomes empty. Another exception is thrown out saying that out of bound.
Anyone can tell me how can I get it right?
Thx
|
|
|
|
|
Don't know about Word automation, but maybe it expect different type of SAFEARRAY - now you are passing to him an array of VARIANT s of type VT_I4 , maybe he want's to accept only array of VT_I4 directly.
Or another possibility is, when I did something small with Word, he expected some number, but because it was optional, it had to be stored in VARIANT , so I feed him with VARIANT with VT_I4 , but it failed with 'Bad parameter'. After playing a bit I found, that the beest expect to be filled with type set to VT_I2 and suddenly everything worked...
Hope this helps.
|
|
|
|
|
Have I understood this correctly, you want to receive a SafeArray from your call to shapes.Range ()? And this SafeArray will be populated with ULONGS?
Have a look at Chris Sells' SAFEARRAY Wrapper class:
http://www.sellsbrothers.com/tools/comvector.h
You should use it like this, where Size is the number of elements you are expecting back:
<br />
CComVector<ULONG> v (Size);<br />
CComVectorData<ULONG> rg (v);<br />
SAFEARRAY* sa = 0;<br />
v.DetachTo (&sa);<br />
<br />
CShapes shapes(doc.GetShapes());<br />
CShapeRange sr(shapes.Range(sa));<br />
<br />
for (int i = 0; i < rg.Length (); i++)<br />
{<br />
DWORD Value = rg[i];<br />
}<br />
Hope this helps
Jon
|
|
|
|
|
Hi
How to detect, if EXE COM is running form other application via COM call?
I 'd like to disable running executable COM as standalone application.
Thx 4 hlp
|
|
|
|
|
Running COM objects are registered in the ROT (Running Object Table). To get the ROT, just use the GetRunningObjectTable(...) WIN32 API function.
|
|
|
|
|
What language are you using? If VB6 then:
>The App.StartMode property will tell you whether you are running in standalone mode
>You can disable stand-alone execution by setting the start mode option to "ActiveX Component" in the Component tab of the Project Properties.
>VB objects are not registered in the running object table unless you register them there.
|
|
|
|
|
I use C/C++ in the executable COM and in the client.
|
|
|
|