|
check if the dll is already in use some where else in some other process...i think this should solve your problem....
regards
|
|
|
|
|
If your COM server happens to be a .exe, then be sure to know that by default IIS won't start more than 2 .exe COM instances.
|
|
|
|
|
Hi All,
I’m handling events of ADO in an ATL out-of-process server, and for some reasons when I use _ATL_FREE_THREADED declaration event ConnectComplete is not called when I establish an asynchronous connection, thou it is called when I use a synchronous connection. Changing the memory model to _ATL_APARTMENT_THREADED solves the problem, but what is the reason of such strange behaviour anyway, and what’s the
proper solution?
Regards,
Vitaly Tomilov
|
|
|
|
|
I'm implementing a COM add-in for Outlook using C#. I have added an event handler to the Outlook.Explorer BeforeFolderSwitch event as follows:
m_activeExp.BeforeFolderSwitch += new Outlook.ExplorerEvents_10_BeforeFolderSwitchEventHandler( this.OnBeforeFolderSwitch );
The event handler method is as follows:
public void OnBeforeFolderSwitch( object newFolder, ref bool cancel )<br />
{<br />
MAPIFolder oNewFolder = (MAPIFolder)newFolder;<br />
if ( oNewFolder.Name.Equals( "Rhythmyx" ) )<br />
{<br />
if ( m_psSessionID == null || m_psSessionID.Trim().Equals( "" ) )<br />
{<br />
LoginForm loginForm = new LoginForm();<br />
if ( loginForm.ShowDialog() == DialogResult.OK )<br />
{<br />
}<br />
else<br />
{<br />
cancel = true;
}<br />
loginForm.Dispose();<br />
}<br />
}<br />
}
The "cancel = true;" statement should prevent the folder switching, but for some reason, it does not. FWIW, I have the same code in a VBA module (prototype), and setting the cancel parameter to True indeed prevents the folder switch.
Any ideas why this is not behaving as expected?
Thanks,
--
Roy
|
|
|
|
|
May be a dummy note, but are you sure cancel = true; is executed ? (ref bool cancel is the right parameter signature, it should work!).
|
|
|
|
|
Not a dummy note at all -- and thank you for the reply.
I am sure, and here's the call stack after I set cancel to true:
> rx5.dll!Rx5.Connect.OnBeforeFolderSwitch(System.Object newFolder = {System.__ComObject}, bool cancel = true) Line 221 C#
The only thing that makes me wandr is why the call stack does not show the cancel parameter as a ref parameter -- the method signature is as follows:
public void OnBeforeFolderSwitch( Object newFolder, ref bool cancel)
Could it be that the Outlook interop DLL somehow treats cancel as a value parameter?
I'd be more then happy to send me code for someone else to try it out.
--
Roy
|
|
|
|
|
I am trying to write a DLL to be called from VB. Thus I had to use SAFEARRAY.
I have a problem that when I am accessing all the elements in the array I can change their values but when I try to access a specific element it seems not to accept the new value I try to assign.
For example, I have these functions:
void Set2DSafeArrayPtr(SAFEARRAY * psaiInOut, long val)
{
long ai[2];
int x,y;
LRESULT hres;
int xMin = psaiInOut->rgsabound[0].lLbound;
int xMax = xMin + (int)psaiInOut->rgsabound[0].cElements - 1;
int yMin = psaiInOut->rgsabound[1].lLbound;
int yMax = yMin + (int)psaiInOut->rgsabound[1].cElements - 1;
// Set up dimension array and pointer to receive value.
long * piInOut;
if (hres = SafeArrayLock(psaiInOut)) throw hres;
for (x = xMin; x <= xMax; x++) {
ai[0] = x;
for (y = yMin; y <= yMax; y++) {
ai[1] = y;
hres = SafeArrayPtrOfIndex(psaiInOut, ai, (void **)&piInOut);
if (hres) throw hres;
// Equivalent to: aiInOut(x, y) = aiInOut(x, y) + 1.
(*piInOut) = val;
}
}
if (hres = SafeArrayUnlock(psaiInOut)) throw hres;
}
void SetElementPtr(SAFEARRAY * psaiInOut, int x, int y, long val)
{
LRESULT hres;
long * piInOut;
long ai[2];
if (hres = SafeArrayLock(psaiInOut)) throw hres;
ai[0] = x;
ai[1] = y;
hres = SafeArrayPtrOfIndex(psaiInOut, ai, (void **)&piInOut);
if (hres) throw hres;
(*piInOut) = val;
if (hres = SafeArrayUnlock(psaiInOut)) throw hres;
}
my program
void main{
...
SAFEARRAYBOUND bDim[2];
bDim[0].lLbound = 0;
bDim[0].cElements = 6;
bDim[1].lLbound = 0;
bDim[1].cElements = 6;
psaiNew = SafeArrayCreate(VT_I4, 2, bDim);
if(psaiNew == NULL){
cout << "Unable to initialize array. Not enough memory" << endl;
return;
}
hres = SafeArrayLock(psaiNew);
Set2DSafeArrayPtr(psaiNew, 15);
SetElementPtr(psaiNew, 1,2,30);
hres = SafeArrayUnlock(psaiNew);
...
}
The Set2DSafeArrayPtr seems to work fine but the SetElementPtr doesn't seem to work.
Any idea why? What am I doing wrong?
I'd also like to know of a good place I can find references/examples (other then MSDN)...
|
|
|
|
|
This code works fine in a MDI application. The error must come from somewhere else.
rechi
|
|
|
|
|
I have written a COM component in VC++ that connects to a ODBC (.mdb file) through OLE DB. When i try to use it in .asp page i get error (0x80004005 - unspecified error). The same component (same asp file) works fine with PWS under Win98. When i run the same with IIS5 in Win2000 and WinXP i get error. I couldn't find out what might be the problem. Can you help me out?
Thanx in advance
Mahesh
|
|
|
|
|
hi there..
thanks for your time first..
i wanted to know if you may have some source of information on what does the variable m_ObjectType does in the Class CAutomationObject does??
help is desparately needed..
thanks
regards
safee
|
|
|
|
|
I compiled and linked some sample source code got from Microsoft SDK, there were some strange link errors:"error LNK2001: unresolved external symbol "error LNK2001: unresolved external symbol "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z)" and "error LNK2001: unresolved external symbol "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z)", it caused by such code:"_TCHAR *szName = new _TCHAR[100]" and "delete []szName".I tried to change the project setting option, but it still happened. I just wonder if there is anyone once met such problem before and how to solve it. Thank you.
Ray
|
|
|
|
|
It seems like you have problems with unicode.
Are the settings OK for that?
|
|
|
|
|
How to extract the content of the _variant_t if
the VARTYPE is VT_DISPATCH?
thank you
|
|
|
|
|
Cast it to LPDISPATCH .
rechi
|
|
|
|
|
ppdispVal
[ It is possible to represent everything in this universe by using 0 and 1 ]
|
|
|
|
|
I have project that is based MFC, in this project, i want to catch new event of Word in AutoMation, and now i can catch sample enent, such as "DocumentChange", "Quit", but i can't catch "DocumentOpen" "DocumentSelectChange" etc new event, why? please tell me
how to do, thanks a lot!
Hello everyone
|
|
|
|
|
http://www.codeproject.com/com/adWordAddin.asp
|
|
|
|
|
Hi all,
Can I build ActiveX Control that implements the multithread features? What I means is the control that operate the background process and user can stop its operation.
Why do I need this control? It seems like a console UI control that I can key any commands on this control and then it sends the command to a hardware via serial comm port. After that the hardware send back data to buffer. The control reads back and display on the console. I found some difficulties on this model. If the hardware sends a long operation data, UI control is freezed, I can't key any commands to break it.
Thank you very much
champ
|
|
|
|
|
Please read this article [^] before applying any threading work inside ActiveX control.
|
|
|
|
|
Is there a simple way to determine the location of a COM server for a given CLSID?
I know that given a CLSID, I can convert to a string and look it up in the registry "HKEY_CLASSES_ROOT\CLSID\<clsid>" - I can then look at the key (for example) "InprocServer32" and find the server name/location.
Incidentally, there is some code to do this and more here[^]. This is great but I just thought there may be some macro or API call I'm missing which can do it without me having to explicitly look it up in the registry.
"The folly of man is that he dreams of what he can never achieve rather than dream of what he can."
"If you think education is expensive, try ignorance."
|
|
|
|
|
you can use the OLE/COM object viewer of VC++. There you can find all the COM objects you have registered (and typelibs).
|
|
|
|
|
Thanks, but I needed to find my server from within my COM client's code.
I still think there must be a way of doing it but my workaround was to implement a method for my coclass(es) which returns the containing server's name/location (in-proc DLL).
My specific requirement was for my client to be able to load a resource (icon) from the server. Once I have the server's name/location, it's then easy to call (for example) ExtractIcon(Ex)() . I still don't think this is the most elegant solution but hey it seems to work
"The folly of man is that he dreams of what he can never achieve rather than dream of what he can."
"If you think education is expensive, try ignorance."
|
|
|
|
|
Hello,
Application
-----------
I've created a multi-tier application. Its architecture is:
On client machine --> the client application is an ActiveX EXE component (VBasic).
On server machine --> some COM+ server applications and a SQLServer database.
Use Case
--------
CLIENT1
--> asks SQLServer database for an object (= a row in objects table).
The state of this object is stored in a storage file.
--> if the object can be check out, it means nobody else have checked out the object,
the server will set the objects.checkedoutby = ClientID and will copy the stg file
in a shared folder on server machine.
CLIENT2
--> tries to check out the same object
--> the server must know (??? - MY QUESTION IS ABOUT THIS POINT) if the CLIENT1 application
is still running or a crash has occured and CLIENT1 was not able to check in the object.
Remarks
-------
1) CLIENT2 will receive a copy of the storage file if CLIENT1 is still running
2) CLIENT2 will have the possibility to restore the storage file from
an older version if a crash occured in the CLIENT1 application.
3) Many clients can log in using the same account (user name and password)
4) There can be more than one instances of the application on the same client machine
My solution
-----------
My solution is to create an instance of an "watchdog" ActiveX EXE on the client machine
when the client application is started. This "watchdog", from time to time (5 minutes by example),
will modify the value of a date field named NotificationDate in database.
When the client application shuts down, the "watchdog" will stop updating that field.
The stored procedure responsible for check out will use the value of NotificationDate field
to decide whether the CLIENT1 application that use this object is still running or a crash has occured.
Questions
---------
1) Is there a pattern for this problem?
2) What about my solution?
10x,
Ovidiu
|
|
|
|
|
Hi,
I'm rather new to COM. I was working with the ATL/COM wizard in VC++ and I tried to overload an interface method. But the wizard doesn't let me do this. It says that the name conflicts with an existing name. Is there any way I can actually overload an interface method in VC++?
Thanks in advance
|
|
|
|
|
you MUST implement an interface in the class where it is used as the base interface..if u dont implement an interface it will not compile and ask for the implementation of the interface in the inherited class..
so here are the steps...
1. make a new class..
2. make it inherit from the Interface u just made..
3. Implement all the methods that the interface has got, in the class..if u dont want to implement a method, make it return E_NOTIMPL!
|
|
|
|