Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: change the font color from coding Pin
Hamid_RT1-Sep-06 20:29
Hamid_RT1-Sep-06 20:29 
QuestionHow can change color of dialog box Pin
sheshidar1-Sep-06 19:10
sheshidar1-Sep-06 19:10 
AnswerRe: How can change color of dialog box Pin
_AnsHUMAN_ 1-Sep-06 19:37
_AnsHUMAN_ 1-Sep-06 19:37 
GeneralRe: How can change color of dialog box Pin
sheshidar1-Sep-06 19:50
sheshidar1-Sep-06 19:50 
GeneralRe: How can change color of dialog box Pin
Hamid_RT1-Sep-06 20:02
Hamid_RT1-Sep-06 20:02 
GeneralRe: How can change color of dialog box Pin
sheshidar1-Sep-06 20:18
sheshidar1-Sep-06 20:18 
GeneralRe: How can change color of dialog box Pin
_AnsHUMAN_ 1-Sep-06 20:10
_AnsHUMAN_ 1-Sep-06 20:10 
QuestionLocal Automation works, remote doesn't Pin
garyflet1-Sep-06 13:28
garyflet1-Sep-06 13:28 
Hi Gurus,

I'm using Visual C++ 6 and somewhat familiar with using Automation locally.
I am hoping to communicate with a program over the network as easily as I do
it locally.

Here is some code (note the comments):
CString strPCName;
GetDlgItemText(IDC_EDT_REMOTE,strPCName);

//m_PIDatsApp is a COleDispatchDriver wrapper class
if (strPCName.IsEmpty()) //local
{
m_PIDatsApp.CreateDispatch("PIDats.Application");
}
else //remote
{
LPDISPATCH lpDispatch = GetRemoteDispatch
(L"PIDats.Application",(LPCTSTR)strPCName);
if (lpDispatch)
m_PIDatsApp.AttachDispatch(lpDispatch);
}
m_PIDatsApp.OnFileNew();

LPDISPATCH GetRemoteDispatch( WCHAR* lpProgID, LPCTSTR lpPCName )
{
LPDISPATCH pDisp = NULL;
USES_CONVERSION;
COSERVERINFO SI;
::ZeroMemory(&SI, sizeof(SI));
SI.pwszName = T2OLE((LPTSTR)lpPCName);
CLSID clsid;
::CLSIDFromProgID(lpProgID, &clsid);
MULTI_QI rgmqResults;
IID IID_IUnk = IID_IUnknown;
rgmqResults.pIID = &IID_IUnk;
rgmqResults.pItf = NULL;
rgmqResults.hr=0;
HRESULT hr = ::CoCreateInstanceEx(clsid, NULL, CLSCTX_REMOTE_SERVER,
&SI, //Machine on which the object is to be instantiated
1, //Number of MULTI_QI structures in rgmqResults
&rgmqResults //Array of MULTI_QI structures
);

if( SUCCEEDED(hr) )
{
LPUNKNOWN pUnk = rgmqResults.pItf;
VERIFY(S_OK==pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp));
pUnk->Release();
}
return pDisp;
}

I note that I'm able to start the program (PI_Dats) either way. But if
PI_Dats is on a remote machine, when I get to m_PIDatsApp.OnFileNew(), the
debugger on the server doesn't move past it. I put a message box in the
OnFileNew() function on the server; it did not pop up. However,
OnFileNew() works fine locally. I was hoping that I would be able to work
remotely without many modifications. Apparently I can't do that? What would
be a good source to study to learn how to use Automation functions (I'm
noping I don't have to learn low-level DCOM)?

Another difference is debugging on the server. Locally, I'm able to debug a
server program easily. In this case I try to do that by running the program
on the server with /Embedding as a program argument. But then when I use
GetRemoteDispatch() above, a new instance of the program is created on the
server, so I can't use the debugger on the server. How can I use the debugger
on the server?

Also, once the program has started on the server, I don't know how to stop
it. Using the Task Manager doesn't do it, a message box pops up that says
"Access denied." The only way to stop it is to reboot, which is time
consuming. How can I shut down the program started on the server?

I'm using Windows 2000 on the client computer, Windows NT on the server.

Thanks for any help.


AnswerRe: Local Automation works, remote doesn't Pin
Stephen Hewitt1-Sep-06 17:40
Stephen Hewitt1-Sep-06 17:40 
QuestionRe: Local Automation works, remote doesn't Pin
garyflet2-Sep-06 12:26
garyflet2-Sep-06 12:26 
QuestionCCriticalSection Pin
act_x1-Sep-06 11:22
act_x1-Sep-06 11:22 
AnswerRe: CCriticalSection Pin
Chris Losinger1-Sep-06 11:44
professionalChris Losinger1-Sep-06 11:44 
GeneralRe: CCriticalSection Pin
act_x1-Sep-06 11:54
act_x1-Sep-06 11:54 
GeneralRe: CCriticalSection Pin
Chris Losinger1-Sep-06 12:01
professionalChris Losinger1-Sep-06 12:01 
QuestionConsole MFC Fullscreen Pin
Johpoke1-Sep-06 9:55
Johpoke1-Sep-06 9:55 
AnswerRe: Console MFC Fullscreen Pin
Jun Du1-Sep-06 12:12
Jun Du1-Sep-06 12:12 
QuestionSetWizardMode results in wizard too wide for its page Pin
Owen Lawrence1-Sep-06 9:03
Owen Lawrence1-Sep-06 9:03 
QuestionPointer to CPropertyPage Pin
DanYELL1-Sep-06 7:34
DanYELL1-Sep-06 7:34 
AnswerRe: Pointer to CPropertyPage Pin
Chris Losinger1-Sep-06 9:31
professionalChris Losinger1-Sep-06 9:31 
QuestionCAsyncSocket question Pin
CoolASL1-Sep-06 6:19
CoolASL1-Sep-06 6:19 
AnswerRe: CAsyncSocket question Pin
led mike1-Sep-06 7:48
led mike1-Sep-06 7:48 
AnswerRe: CAsyncSocket question Pin
BrianCharles1-Sep-06 8:00
BrianCharles1-Sep-06 8:00 
GeneralRe: CAsyncSocket question Pin
CoolASL3-Sep-06 1:42
CoolASL3-Sep-06 1:42 
GeneralRe: CAsyncSocket question Pin
BrianCharles4-Sep-06 7:02
BrianCharles4-Sep-06 7:02 
QuestionValidation of matching comments Pin
reddy harish1-Sep-06 4:55
reddy harish1-Sep-06 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.