Click here to Skip to main content
15,920,603 members
Home / Discussions / COM
   

COM

 
GeneralThird party program library method calls invocation Pin
yeeck19-Jun-03 21:14
yeeck19-Jun-03 21:14 
GeneralCOM+ Error Pin
Aky18-Jun-03 23:31
Aky18-Jun-03 23:31 
GeneralRe: COM+ Error Pin
Steve S23-Jun-03 21:50
Steve S23-Jun-03 21:50 
GeneralRe: COM+ Error Pin
Aravinthan25-Jun-03 3:11
Aravinthan25-Jun-03 3:11 
QuestionInproc COM server question? Pin
Obi-Wan-Kenobi17-Jun-03 18:30
Obi-Wan-Kenobi17-Jun-03 18:30 
AnswerRe: Inproc COM server question? Pin
valikac18-Jun-03 6:57
valikac18-Jun-03 6:57 
AnswerRe: Inproc COM server question? Pin
Giles22-Jun-03 5:08
Giles22-Jun-03 5:08 
GeneralMSWord Applications Pin
Madmaximus17-Jun-03 10:01
Madmaximus17-Jun-03 10:01 
Hi everyone,

Does anyone know why I can't seem to run multiple MSWord applications simultaneously? I am running a multithreaded server that opens a Word application per thread. The server then open documents and prints them. It works fine if I put a sleep statement in the code, which suggests that there is a synchronization issue. Here is psuedo code to help explain:

#include <atlbase.h>
#import "C:\WINNT\ServicePackFiles\i386\mqoa.dll" no_namespace
#import "C:\Program Files\Microsoft Office\Office\mso9.dll" raw_interfaces_only
#import "C:\Program Files\Microsoft Office\Office\msword9.olb" raw_interfaces_only rename("ExitWindows","WordExitWindows")

class MSWord()
{
public:
MSWord ()
{
m_hResults = CLSIDFromProgID(“Word.Application”, &clsid);
if (FAILED(m_hResults))
{
throw “Error”;
}
m_hResults = m_pWord.CreateInstance(clsid, NULL);
m_hResults = m_pWord->get_Documents(&m_pDocs);
}

void printDoc(string strDoc)
{
CComBSTR comBstr = strFile.c_str();
CComVariant var(comBstr);

VARIANT vOpt;
vOpt.vt = VT_ERROR;
vOpt.scode = DISP_E_PARAMNOTFOUND;

m_hResults = m_pDocs->Open(&var, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &pDoc);
if (FAILED(m_hResults))
return;

m_hResults = pDoc->PrintOut(&vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &vOpt, &var, &vOpt);

if (FAILED(m_hResults))
{
cout << " Failed to print " << endl;
return;
}

Sleep(20);

pDoc->Close(COleVariant((short)false), &vOpt, &vOpt);
::SysFreeString(comBstr);
}

private:
Word::_ApplicationPtr m_pWord;
Word::DocumentsPtr m_pDocs;
Word::_DocumentPtr pDoc;
CLSID clsid;
};


static void Foo()
{
MSWord msWord;
MsWord.PrintDoc(“Hello.doc”);
}

void main(void)
{
HANDLE hThreads[10];

for (int I = 0; I < 10; ++I)
hThreads[I] = CreateThread(Foo);

WaitForMultipleObjects(hThreads, INFINITE);
}

Is there a way to create only one Word application and pass it to all of the threads? Confused | :confused: I’m using MSVisual C++ 6.6 compiler.

Any help would be greatly appreciated. Big Grin | :-D
Ken
GeneralUse GetActiveObject first Pin
Vi219-Jun-03 19:58
Vi219-Jun-03 19:58 
GeneralRe: Use GetActiveObject first Pin
Madmaximus20-Jun-03 4:56
Madmaximus20-Jun-03 4:56 
GeneralActiveX stock property issue Pin
Marion2817-Jun-03 7:41
Marion2817-Jun-03 7:41 
Questionhow do i know whether an interface is createable or not? Pin
safee ullah16-Jun-03 0:25
safee ullah16-Jun-03 0:25 
AnswerRe: how do i know whether an interface is createable or not? Pin
J. Schermerhorn16-Jun-03 3:54
J. Schermerhorn16-Jun-03 3:54 
GeneralRe: how do i know whether an interface is createable or not? Pin
safee ullah16-Jun-03 19:34
safee ullah16-Jun-03 19:34 
QuestionHow to Implement DllGetClassObject?? Pin
Anonymous14-Jun-03 1:48
Anonymous14-Jun-03 1:48 
AnswerRe: How to Implement DllGetClassObject?? Pin
Anonymous14-Jun-03 2:23
Anonymous14-Jun-03 2:23 
Questioncomponet for INTERNET EXPLORER programming in .NET? Pin
Asim N.13-Jun-03 3:02
Asim N.13-Jun-03 3:02 
GeneralVisual Studio Add-In --&gt; IApplicationEvents save event Pin
Amir Harel12-Jun-03 4:25
Amir Harel12-Jun-03 4:25 
GeneralRe: Visual Studio Add-In --&gt; IApplicationEvents save event Pin
Anonymous19-Jun-03 21:37
Anonymous19-Jun-03 21:37 
GeneralItypeInfo::Invoke paramerters Pin
safee ullah11-Jun-03 23:39
safee ullah11-Jun-03 23:39 
GeneralRe: ItypeInfo::Invoke paramerters Pin
Hans Ruck12-Jun-03 0:37
Hans Ruck12-Jun-03 0:37 
GeneralRe: ItypeInfo::Invoke paramerters Pin
safee ullah12-Jun-03 19:44
safee ullah12-Jun-03 19:44 
GeneralCOM exe under win98 Pin
Ryszard Krakowiak10-Jun-03 21:20
Ryszard Krakowiak10-Jun-03 21:20 
GeneralInvokeHelper.. More info needed! Pin
harinath10-Jun-03 19:16
professionalharinath10-Jun-03 19:16 
QuestionHow call the javascript 'escape' function from C++ ? Pin
Thierry Maurel10-Jun-03 7:24
Thierry Maurel10-Jun-03 7:24 

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.