|
Hello All,
I am very new to com and reading it from Internet.
I was making Exe server and client (both are exe). I able to do that also in Visual studio 2008. If I call class function of exe server from client i am able to do it also.
NOW My Problem is ,
<pre>STDMETHODIMP CDcomClass::GetIntVal(LONG* val)
{
LONG i=105;
*val=i;
printf("\n HI I am from Exe Server \n");
Beep(800,800); return S_OK;
}
In this code I get val in client ,Beep() also run,but printf("\n HI....
is not executed .
Can You please explain me reason.
Thank you.
|
|
|
|
|
Exe server is an out proc server. So, your client cannot see what is printed by the server exe.
|
|
|
|
|
Thanks ,But I want to show this msg to server what should I do
|
|
|
|
|
May be you can check if a log file would work for you.
|
|
|
|
|
If you want to print then change the signature of the function and out parameter as BSTR.
Величие не Бога может быть недооценена.
|
|
|
|
|
I want to connect to the sql server database and do some query command via ado. I use this connection string to do that work:"Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DaDian2008;Data Source=localhost;UID=sa;PWD=123456;Network Library=dbmssocn", it works well. But how about with a remote server(LAN). For example, my ip address is 192.168.1.100, i just replace localhost to 192.168.1.100, it would get an exception says:
Code = 80004005
Code meaning = Unspecified error
Source = Microsoft OLE DB Provider for SQL Server
Description = [DBNETLIB][ConnectionOpen (Connect()).]Specified SQL server not found.
Why? And how can i connect to a remote sql server(MS SQL Server within LAN)?
btw, if I use "Driver={SQL Server};Server=192.168.1.100;Address=192.168.1.100,1433;Network=DBMSSOCN;User ID=sa;PWD=123456;Database=DaDian2008; Then, I can connect to the database on my locale computer, but it would fail again on another computer.
modified on Sunday, March 21, 2010 9:16 AM
|
|
|
|
|
Make sure you can connect with odbcad32.exe before trying your code. Then visit connectionstrings.com for help.
|
|
|
|
|
Hi,
I'm marshalling some data in a timerproc thread using the GetInterfaceFromGlobal and Release function. However I noticed there is a high cpu usage when calling this function multiple times. Any ideas why this is happening?
Thanks
|
|
|
|
|
Hello,
Here is my need,
For each Release, I need to delete some COM+ Components for an Application and install some newer version of the same.
Till day it is accomplished through COM+ Window, I go to Component Services+Computers+COM+ Applications+'Application'+Components and select the components and delete them. Once deleted right click on components and select New->Component and then browse to the new version of dll which install back the components.
I tried to accomplish it through Regcomplus.exe. Issue is, it installs new components but it deletes all existing components under the application leaving just the new ones.
Command executed is "RegComPlus.exe <dll file> <application name>"
Any help on this would be greatly appreciated.
Thanks,
Simon Mandy
|
|
|
|
|
I have made a right-click drag-and-drop shell extension to copy specific project files. It's all working very well at copying files, but it freezes all instances of explorer.exe while it's doing its thing on bigger projects. A colleague told me to put sleep() somewhere in the copying function. I find this approach inelegant and possibly ineffective. There must be a way to make this more user- and thread-friendly. There was also talk of progress bars, but just one thing at a time...
|
|
|
|
|
I want to get the already open excel sheet and get the cell value using IDispatch. Trioum
|
|
|
|
|
|
CoInitialize(NULL);
HRESULT hr;
CLSID clsidExcelApp;
hr = CLSIDFromProgID(L"Excel.Application", &clsidExcelApp);
IUnknown *pUnk = 0;
hr = GetActiveObject(clsidExcelApp, NULL, &pUnk);
if(SUCCEEDED(hr))
{
IDispatch *pDisp = 0;
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp);
CApplication oApp(pDisp);
CWorkbooks oBooks = oApp.get_Workbooks();
CWorkbook oBook = oBooks.get_Item(COleVariant((short)1));
CWorksheets oSheets = oBook.get_Worksheets();
CWorksheet oSheet = oSheets.get_Item(COleVariant((short)1));
oSheet.Activate();
CRange oRange = oSheet.get_Range(COleVariant(CString(L"A1")), COleVariant(CString(L"A1")));
COleVariant var = oRange.get_Text();
MessageBox(var.bstrVal, L"Text in cell A1");
}
|
|
|
|
|
I good I get it . But I am facing two problems
(a) : I am not able to get the cell change event . i.e. as the value in cell change My application get the event that which is cell i.e. its row and col .
(b) as I click on any cell in edit mode application hang .
Trioum
|
|
|
|
|
Get IConnectionPointContainer interface of the application object, and get connection point to the events you want to catch. In this case, i think you have to deal with WorkBookEvents and DocEvents. Several documentations are available..
catching events from word
handling events for excel
create sink event for COM client
Use OLE-COM object viewer to get exact UUID of the events you want to trap.
best of luck.
|
|
|
|
|
I got the event of sheet change but still not getting the value of cell and its location i.e. row and col of cell in the function .
STDMETHODIMP CAppEventListener::HandleSheetChange( IDispatch* xlSheet,
IDispatch* xlRange)
{
OutputDebugString("HandleSheetChange\n");
HRESULT hr = S_OK;
return hr;
}
Trioum
|
|
|
|
|
did u examine the xlRange value? I think it will contain the cell range where the event is fired. Try calling get_Text() on this range to get text in the cell.. see various methods on Range object..

|
|
|
|
|
but i am not getting the get_text() method . in this function .
Trioum
|
|
|
|
|
how did u try it? please show a bit of code..
|
|
|
|
|
STDMETHODIMP CAppEventListener::HandleSheetChange( IDispatch* xlSheet,
IDispatch* xlRange)
{
OutputDebugString("HandleSheetChange\n");
xlRange-> here not gettting text method
HRESULT hr = S_OK;
return hr;
}
Trioum
|
|
|
|
|
oh.. You did exactly as i guessed . xlRange is Range object's IDispatch iterface. If you haven't already done, add a Range class (say CRange) to the project from EXCEL.exe using 'Add MFC Class from Typelib' wizard. Then
CRange oRange(xlRange);
See the methods on Range object now by using oRange. ---- 
|
|
|
|
|
Done it . but exe is crashing as I call getText()
Trioum
|
|
|
|
|
Now by lot of R&D problem is solved . Can you guide me for SheetCalculate event . its example is not given on the site.
Trioum
|
|
|
|
|
well done OLE automation may need some R&D most time.
You can catch SheetCalculate event in much the same way you did for SheetChange event. Mean, all reside in IAppEvent interface, so Advice() for it, and override the SheetCaluclate method.
<br />
HRESULT _stdcall SheetCalculate(IDispatch* pSheetDisp)<br />
{<br />
CWorkSheet oSheet(pSeetDisp);<br />
}<br />
|
|
|
|
|
I got it and do it , but facing one more problem as in case on "change event" I got the cell number i.e its row and column in which value is change . But "calculate event" fire when there is reference of another cell or cell containing formulae and when value change in such cell in this case I am not getting the cell no i.e cell row and column . this is my problem it become very tedious when I have the thousand of such cells having reference of various cells and formulaes. In this case I have to parse every cell to find out the value change . this become very slow for my project .I am searching the way to find out the cell row and column when there is calculate event fire .
Trioum
|
|
|
|