|
Hello everyone,
I've been playing around with Excel Automation for a while now, and I'm having a little problem.
I'm using some classes that VC++ automagically generated from the Excel type library. When I try and close the instance of excel I've created, it seems to work, and no errors or exceptions occur. But after my app terminates there is still an excel.exe shown in NT's Task Manager.
Here is the code I'm using to close Excel (It's probably got loads of unneccesary stuff in, I've been playing with it trying to fix the problem):
m_ExcelWorkbook.DetachDispatch();
m_ExcelWorkbooks.DetachDispatch();
m_ExcelWorksheet.DetachDispatch();
m_ExcelApp.SetVisible( false );
m_ExcelApp.Quit();
m_ExcelApp.DetachDispatch();
m_ExcelApp.ReleaseDispatch();
Hope someone can give me some pointers or a link to RTFM.
TIA,
Pete
|
|
|
|
|
Hello,
If I register my DCOM exe server as local server, it works fine.
If I register it as NT Service, the registration seems good but every call to CoCreateIntance failed with the error ERROR_SERVICE_DOES_NOT_EXIST.
If I try to configure with DCOMCNFG.EXE, it prompts the service is installed but it show the same error when I want to apply the modification.
When I go in the Service window, my service is present and I can run it/stop it via the Service Manager. In the EventViewer, I can see the info/warning/error message the server drops.
The DCOM server is developped under VC++ 6.0 with ATL.
Can you give me a hint on how to solve that problem?
I have read the Richard Grimes' book but found nothing. I read it again and again wo any success.
Thanks,
Bruno
|
|
|
|
|
|
I got it.
The name of the LocalService appid entry does not match the service name.
I have chnage the IDS_SERVICENAME and ATL use a hardcoded name one time and I miss to change it.
|
|
|
|
|
Dear All,
I was trying to deploy a application into COM+ which is working fine out of COM+. But it fails to pass an Object ref from one COM+ component to another.
Can somebody help me out/drop a hint ASAP?
The process goes like this.
SERVER-1, SERVER-2, OBJECT are three components deployed in COM+.
---------------------------------------------------------------------------
SERVER1 :
GetObjectContext(&objcon);
objcon->CreateInstance(OBJECT CLSID,.., &obj);
VARIANT vobj;
vobj.vt = VT_VT_DISPATCH; vobj.pdispVal = obj;
printf("%u", vobj.pdispVal ); // display valid address
objcon->CreateInstance(SERVER2 CLSID,...);
SERVER2->func2(vobj);
---------------------------------------------------------------------------
SERVER2 :
printf("%ld", vobj.vt ); // display 9 correct
printf("%u", vobj.pdispVal ); // display 0 i.e. NULL
Tools Used : VC++6, ATL3, Windows2000
Thanx in advance.
Regards,
Rohit Arora
www.dsrsolutions.com
Rohit Arora
|
|
|
|
|
How you define "SERVER2->func2(vobj);" in .IDL file?
soptest
|
|
|
|
|
Dear Soptest,
SERVER2.idl defines function as
[id(2), helpstring("method func2")] HRESULT func2(VARIANT vobj);
Regards
Rohit Arora
VC++ Team Member
rohita@dsrsolutions.com
|
|
|
|
|
You must provide [in] attribute of the argument. Try this:
[id(2), helpstring("method func2")] HRESULT func2([in]VARIANT vobj);
soptest
|
|
|
|
|
If I think right, [in] is the default IDL-method- attribute. Even then I tried, but as expected shows no change in results
Clearly the problem is "The COM+ object reference is valid in the apartment/context where object instance was created, but goes invalid once it is passed to another COM+ component by the originator."
So, being new to COM+, I guess the solution is to marhall the reference on my own, or possibly other solutions exist, hopefully you guys/gals can suggest.
It'll be kind if somebody can explain what Don Box tries to say under "Context Relativity" in this article :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmsj99/html/complusprog.asp
Regards
Rohit Arora
VC++ Team Member
rohita@dsrsolutions.com
|
|
|
|
|
If I have a component, that's not an activeX control, that implements connection points, how do I recieve the events from script? I'd like to do something like the following :
<script language="vbscript">
Dim obj
Set obj = CreateObject("XYZ.SomeObject")
Sub ISomeObject_OnSomethingHappened()
'Event was fired, handle it...
End Sub
</script>
Another example is MSXML. The MSXML DOM implements events that can be handled from script. How is this done?
<script>
var xmldoc;
function Load()
{
xmldoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
xmldoc.onreadystatechange = CheckState; <<-- How do I implement this functionality in my component???
xmldoc.load(URL.value);
}
function CheckState()
{
}
</script>
Thanks....
|
|
|
|
|
This is a problem I'm having that is along similar lines to Gerald, I'm trying to use events that are implemented in a com server I created, using JavaScript. I have already implemented a Visual Basic application that works fine with it, and handles the events from the server, so I am confident that the server works fine.
I have also implemented HTML and JavaScript that connects to the sever throught the <object> tags, and it can call functions, and use properties from it, but I can't get it to handle the events from it using tags.
Does anyone know if there is there anything specific I have to implement in the Server, or the JavaScript to make this work?
Cheers,
Dave.
|
|
|
|
|
I have an ATL COM dll with MFC support and am trying get an File dialog to display, I can understand why a CFileDilog would not work, I guess. So I tried to use the GetOpenFileName() function. But whilst this compiles it doesn't display the dialog, it olny return the error code 2, which stands for file can't be found. The code segment I have used is below, if anybody has any ideas I would really like to hear them, Please....
long lErrMsg = 0;
OPENFILENAME ofn;
TCHAR sfile[MAX_PATH];
ZeroMemory(&ofn, sizeof(ofn));
ZeroMemory(sfile, sizeof(TCHAR)*MAX_PATH);
#ifndef NULL_TERMINATE
// Not NULL terminated.
{
int i;
for (i = 0; i < MAX_PATH; i++)
sfile[i] = ' ';
}
#else
// NULL terminated.
sfile[0] = '\0';
#endif
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = sfile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = NULL;
ofn.nFilterIndex = 1;
ofn.lpstrTitle = TEXT("Please Select a File");
ofn.lpstrInitialDir = NULL;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = NULL;
ofn.lCustData = 0;
ofn.lpfnHook = 0;
ofn.lpTemplateName = 0;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
// Call GetOpenFileName().
if (GetOpenFileName(&ofn))
{
MessageBox(TEXT("GetOpenFileName() Successful"), TEXT("OpenDialog"), MB_OK);
}
else
{
TCHAR sErrMsg[256];
lErrMsg = CommDlgExtendedError();
wsprintf(sErrMsg,TEXT("Error %d returned from GetOpenFileName()"), lErrMsg);
MessageBox(sErrMsg, TEXT("OpenDialog"), MB_OK);
}
Cheers
|
|
|
|
|
The Problem is here
{
int i;
for (i = 0; i < MAX_PATH; i++)
sfile[i] = ' ';
}
You generate file name as array of spaces.
get rid of it.
and use :sfile[0] = '\0';
soptest
|
|
|
|
|
Cheers, it worked a treat !!
|
|
|
|
|
Please help I am going crazy...
I'm using Windows 2000.
I make my ATL .EXE Server.
I make my C++ MFC client on the same machine.
run the code below via the client and get an E_NOINTERFACE error... what does this error actually mean...what do I have to change....? any ideas ?
Note that the .EXE does seem to have an Hello world interface exposed ? help me please, I've looked in OLEView and the registry and the .EXE object seems to be there. I've fiddled about with DCOMCNFG.EXE to try and configure it so that client/server run on the same machine and no such luck:
{
....
CoInitialize(NULL);
IExeServer* pIHelloWorld = NULL;
HRESULT hr = CoCreateInstance (CLSID_ExeServer,
NULL,
CLSCTX_LOCAL_SERVER, // note its a local.
IID_IExeServer,
reinterpret_cast(&pIHelloWorld));
if (hr == E_NOINTERFACE)
{
AfxMessageBox("CLASS_E_NOINTERFACE"); // this error is always
// there
}
if (FAILED(hr))
{
AfxMessageBox("FAILED");
CoUninitialize();
EndDialog(TRUE);
return TRUE;
}
CoUninitialize();
john s.
|
|
|
|
|
I'm using an ActiveX, a DCOM server and IIS.
On the IIS server (the one provided by Win2000), I have installed the DCOM server and put the ActiveX packaged in a cab file with the tlb and inf files.
I have created a html page where I use the ActiveX with some parameters:
- name of the DCOM server
- name of the alias to complete information give by the DCOM server
I go on a client machine on the same room, open IE and point to my page. IE download and install the ActiveX + DCOM TLB + interface marshalling.
The connection is ok, I can use the ActiveX and make request to the DCOM server.
I go on another client (not the same room and not the same domain, but the domains are trusted), I open IE and point to the page. IE download and install the ActiveX + DCOM TLB + interface marshalling.
The connection is KO and I can't create interface. More, it crashs the win2000 OS and I got a blue screen.
What is the safe way to use DCOM over Internet?
Thanks,
Bruno
|
|
|
|
|
Hello All,
Need help on Programming MSWord with Storage streams. I would like to create my own stream in a new document which will be saved by the user. Can i do that, plz help if anybody knows the solution ASAP. Thanx in advance.
|
|
|
|
|
Hi !
I have a VB app which runs an ActiveX (let's call it myActiveX1). This ActiveX has been developped in VB as well.
Then, my app runs several other ActiveXs, performing different tasks, and these ActiveX will have to refer to myActiveX1 in order to perform these tasks. From time to time, myActiveX1 will raise an event that I want to be able to capture from the other running ActiveX.
I believe that my app, when running the other ActiveX, will have to pass them, by one way or another, a pointer (or something similar) to myActiveX.
I have no idea how I could do that in VB ! I definitely don't want to instanciate a new myActiveX in each running ActiveX.
Thank you for your help !
Jerome
|
|
|
|
|
Can a object set to call a function from within a Win32 .dll be considered a COM object? What exactly are the requirements for something being termed a COM object, is it only language independence? Thanks.
Nick Parker
|
|
|
|
|
Properly supporting the IUnknown interface is basically the only requirement.
There are other requirements that make it compatible with languages like VB and VBScript, but they are not necessary in order to call your object a COM object.
If there are any other questions, or you want more detail feel free to ask.
|
|
|
|
|
A COM object implements at minimum the IUnknown interface and has the proper vtable layout in memory (as defined in the COM spec). There are also rules regarding querying interfaces, for example a QI for IUnknown must always return the same value.
--Mike--
It's hammer time!
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
The program, in C++, is sending a call to a DCOM object installed on a remote NT machine, and am trying to return a Safearray of float (as SAFEARRAY **ppfloatarray), have set that parameter as [in,out], (plus other parameters before this as [in]). Client is running Windows 98. On the client end, the data is not being written back to the passed-in safearray, and HRESULT returned is 8002000D, array is locked.
How is the client and server to be set up to do this? My solution was to try various combinations for the flags in the fFeatures member of the safearray, also to try setting the array to locked or unlocked before it was sent and before it was returned from server. I have a debug text file written, so I know that the DCOM object is executing, and the correct values are written to the safearray and are there just before it returns.
David Spain, C++ Applications Programmer
|
|
|
|
|
Hi David,
Can you put parts of your code in this forum? Specially those parts where
you are accessing and unaccessing the SAFEARRAY. It will be better if you
can also give us the portion of the IDL that describes the prototype of the
interface method where you are having the problem.
With best regards,
Sayan
(sayanmukherjee@indiatimes.com)
|
|
|
|
|
Ok, here is the code in question:
I was wanting to return a safearray of BSTR, but was having trouble with that, so thought maybe it had to do with the pointers, so tried float safearray, but is having same problem. This is the code with float safearray: >>> psaFloatReturn is the safearray in question <<<
IDL code:
[
object,
uuid(13AE8E35-3726-11D6-9913-000102476F95),
dual,
helpstring("IRemoteServerDisp Interface"),
pointer_default(unique)
]
interface IRemoteServerDisp : IDispatch
{
[id(2), helpstring("method Method2")] HRESULT Method2([in] BSTR sName, [in] SAFEARRAY(float) *psafloatAr1, [in] SAFEARRAY(VARIANT_BOOL) *psaBoolAr, [in] SAFEARRAY(float) *psafloatAr2, [in] long cnt, [in] float singlefloat1, [in] float singlefloat2, [in,out] SAFEARRAY(float) *psaFloatReturn, [out,retval] long* errcode);
};
--------------------
CoClass method:
STDMETHODIMP CCoRemoteServer::Method2(BSTR sName, SAFEARRAY **psafloatAr1, SAFEARRAY **psaBoolAr, SAFEARRAY **psafloatAr2, long cnt, float float1, float float2, SAFEARRAY **psaFloatReturn, long* errcode)
{
.
.
.
float HUGEP *pfloatTemp;
long val = SafeArrayAccessData(*psaFloatReturn, (void HUGEP**)&pfloatTemp);
float sldk = 3.0f;
for(int q=0; q<count; q++)
="" {
="" sldk="" +="1.0f;" test="" values
="" pfloattemp[q]="sldk;
" }
="" safearrayunaccessdata(*psafloatreturn);
="" safearraylock(*psafloatreturn);="" ???
="" *errcode="S_OK;
" return="" s_ok;
}
---------------
client="" code:
passed="" in:="" cstring="" sname,="" int="" cnt,="" float*="" pfloatarray1,="" bool*="" pboolarray,="" pfloatarray2,="" float="" float1,="" float2,="" long*="" errcode
{
="" safearraybound="" sab;
="" sab.llbound="0;
" sab.celements="cnt;
" safearray*="" psafloatreturn="SafeArrayCreateVector(VT_R4," 0,="" cnt);
="" initialize="" other="" parameters="" here
="" **="" safearray="" **
="" safearraylock(psafloatreturn);
="" tempfloat="new" float[cnt];
="" psafloatreturn-="">pvData = tempfloat;
SafeArrayLock(psaFloatReturn);
// call to DCOM object
BSTR bstrName = sName.AllocSysString();
HRESULT hResult =
m_pRemoteServer->Method2(bstrName, &psafloatar1, &psaBoolAr, &psafloatar2, cnt, float1, float2, &psaFloatReturn, errcode);
SysFreeString(bstrName);
SafeArrayDestroy(psafloatar1);
SafeArrayDestroy(psafloatar2);
SafeArrayDestroy(psaBoolAr);
bool ret = false;
if(SUCCEEDED(hResult))
ret = true;
if(psaFloatReturn!=NULL)
SafeArrayDestroy(psaFloatReturn);
delete []tempfloat;
}
About the count in initializing and returning, I know that the count on both ends is the same and matches the cnt variable given here, so is not an issue of writing past array boundaries.
Thanks in advance for any help.
David Spain, C++ Applications Programmer
|
|
|
|
|
No need for anyone to spend any more time on this --
Sorry if anyone spent time on this, I think there is code on this website in the articles that would help me. In the COM section, "STL Compliant Class for SafeArrays", the code returns safearrays from a COM object, which was my problem. There may be other articles as well. I will look at that to find out what I am doing wrong, so no need for anyone to look at this any further, thanks for the effort.
David Spain, C++ Applications Programmer
|
|
|
|
|