|
|
I know about ShellExecute() and ShellExecuteEx().
However I have to format those office files (.doc,.xls,.ppt) such as formating the page setup like page size, margins, quality, paper size, etc., formating font size, and also printing out embedded objects in word document. Therefore, I have to use automation.
However, I am encountering the error in my program.
The function is marshalled to other thread
here what I do,
I have a dialog that has 3 buttons, print, stop printing, and exit.
when you click print, the program will get files name from database and send it to printer. The printer send message (window message) END_DOC when the file get printed and the program catch the message and send the next file. Meanwhile, if the user click on stop printing button, the program stop immediately.
Inorder to stop printing, I have use following code.
dlg->openApps() opens ms word, excel, and powerpoint application just simply using CreateDispatch().
dlg->closeApps() closes or quite applications.
PrintTheFile() gets the file name, and send it to printer
<br />
UINT PrintingThreadFunction(LPVOID lParam)<br />
{<br />
CMyProgDlg *dlg = (CMyProgDlg *) lParam;<br />
bool openapps = true;<br />
dlg->openApps();
while(!stopprinting)
{<br />
if(isprinting == NO)
{ <br />
dlg->PrintWordDoc() ;
}<br />
if(stopprinting == (int)YES || dlg->quite)<br />
break;<br />
} <br />
dlg->closeApps();
}<br />
<br />
<br />
void CMyProgDlg::OnBnClickedPrint()<br />
{<br />
CWinThread *printingThread; <br />
printingThread = AfxBeginThread(PrintingThreadFunction,this);
printingThread->m_bAutoDelete = FALSE;<br />
}<br />
To catch the message sent by printer I used following code.
<br />
LRESULT CMyProgDlg::OnPrinterMsg(WPARAM wParam, LPARAM lParam )<br />
{<br />
.....<br />
.....<br />
case End_DOC:<br />
PrintWordDoc();<br />
}<br />
Opening and closing office applications take 7 secs to open and 7 sec to close. I want to speed up my program by opening those applications once and close it at when user quite the program.
How to just open those applications once and open the document over and over again with exiting application (.doc with msword, .xls with excel, .ppt with powerpoint)?
thank you
|
|
|
|
|
I am trying to start an application on a remote PC with CreateProcess(), but it is executed on the local PC instead. You will see that I just call CreateProcess() putting "\\otherPC" in front of the path of the application. The code is listed below:
PROCESS_INFORMATION processInfo;
STARTUPINFO startupInfo;
GetStartupInfo(&startupInfo);
DWORD processCreationFlag=CREATE_NEW_PROCESS_GROUP|CREATE_SUSPENDED;
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.wShowWindow = SW_SHOWNORMAL; // SW_SHOWMINIMIZED;
strcpy(startupInfo.lpDesktop, "");
startupInfo.lpTitle=NULL;
char *startingFolder=strdup("\\\\otherPC\\C\\DIM\\ImsVisualization\\bin");
char applicationName[512];
sprintf(applicationName, "%s\\iMSVisualization.exe", startingFolder);
if (CreateProcess(applicationName, NULL, NULL, NULL, true, processCreationFlag,//|CREATE_NEW_CONSOLE,
NULL, startingFolder, &startupInfo, &processInfo)==0)
{
printf("Could not start Visualization\n");
}
else printf("Visualization started successfully\n");
return 0;
|
|
|
|
|
You can't use CreateProcess() in this fashion. What you've done is run an application, that resides on another machine, on the local machine. Search CP and MSDN for RPC examples.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,i am a newer at here.As we all know , "HINSTENCE" and "HWND" are different data types in VC++,there are two datas which defined as each of them,can i send the same value two the two datas,if can , how can i do this ?
Thanks!
|
|
|
|
|
Both HWND and HINSTANCE are handles (void*) and could be assigned the same value!?! Though for the life of me I can't see why
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
plz can any one help me in calculating the time, that will be taken in playing the audio file using c or vc++ program.
|
|
|
|
|
Near the beginning of the file is some header information. One of the fields is the average bytes per second (i.e., sampling rate). Divide this into the size of the file to get the approximate play time. For example, the The Microsoft Sound.wav file is 135,876 bytes in size and has a sampling rate of 22.50 kHz, which yields 6.038 seconds. Opening that same file with Sound Recorder shows that it is 6.12 seconds in length. Does that help?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I need to know when a user defined time has elapsed for communication reasons.
The time is typically within the range of 1 to 20 ms.
I am fully aware of windows not being a RTOS, but that is not the problem.
My problem is that I get much better results with a PII 800MHz CPU running WinNT than with a P4 2.4GHz CPU running WinXP.
I have tried both a waitable timer solution and a multimedia timer solution with exactly the same results. There is no difference between setting the mm-timer resolution to 1 or 0.
While trying to nail this down I have created a small app that simply creates a timer and waits for it with WaitFor...() with no other threads involved.
If I set the due time to 10ms I get variations between 9 and 10ms in the PII environment, but in the P4 environment I get variations between 0 and 15ms.
I would understand if the timer event got signaled later than expected in the PII environment but this is not the case, it sometimes gets signaled long before the expected due time. Boosting process or thread priorities doesn't help.
In the original app where I discovered the problem the time differences are measured with independant hardware.
MSDN documentation about waitable timers says something like "the timer accuracy depends on the hardware capability". I just don't understand why "better" hardware performance is worse.
This is how I do it in pseudo-code:
CreateWaitableTimer
QueryPerformanceCounter
SetWaitableTimer
WaitForSingleObject
QueryPerformanceCounter
What's wrong with this picture?
How can "better" hardware and OS perform worse than older?
Is it an OS or BIOS setting I am unaware of?
Any comments are very welcome.
Thanks in advance
--
Rog
|
|
|
|
|
Maye a different crystal oscillating frequency is being used between the two machines. CPU speed is irrelevant.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This problem is not a processor problem rather a motherboard chipset problem.
PerformanceCounter problems have been reported by other people, and are attributed to problems with certain chipsets. Specifically, some chipsets fail to carry the rollover from bit 23 into bit 24, or do so spuriously, depending on the interval between successive calls to QueryPerformanceCounter.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
That's true.
But even if I could be exposed to such a chipset and it could be an error in the measurement method regarding my test application, it doesn't explain why the PII WinNT env. is more accurate when measuring with hardware.
Thanks anyway
--
Rog
|
|
|
|
|
I agree given that it is the same hardware (chipset) you are running the tests on.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
HI ,
How can I Create DSN for my Database
That is for database provided with my program to user..
i wanna Create DSN through my Code is it Possible
or some other way
I m using VC++ and Access as Database.
Rely me thanx
|
|
|
|
|
Zeeshan Bilal wrote:
How can I Create DSN...
By using SQLConfigDataSource() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
am new at this and have a project to send hci commands via the usb port to a bluetooth dongle. Any idea how i could approach this.
Thanks.
|
|
|
|
|
As we all know,the right bottom of the window has a little triangle,how to change it's color.Maybe it's a little question,but it's important for me,can you help me?
hiall
|
|
|
|
|
If you're reffering to the resize-grip, it's appearance is not typically changable.
What you can start experimenting with is overriding OnNCPaint, letting windows/mfc draw the grip, and then overriding just the grip to whatever you want it to be...
|
|
|
|
|
Hi there
Sorry for the Slopy Subject line!.
What i whant to know is the following.
I have declared a vector of person Objects
vector(person) people; //in main
I have a confrence class
class conf<br />
{<br />
public:<br />
conf(const string &nm, int d);<br />
void set_venue(venue *);<br />
void cancel_venue();<br />
private:<br />
string conference_name;<br />
int duration;<br />
venue * pvenue;
}
I Have added a data member to the conf class which is
a vector of pointers to person
vector(person *) registered;
and the following member function to register a person
who choose to attend a conference.
void register_person(????);
So this is what i must do, ok so person objects where added to people //vector(person)people;
The person running the program gets to decide who will
attend a certian confr thus needing to register this person for the confr.
By index how would i pass the address of the specified person object to my register_person(????); function and get register_person(????); to append this person object
to my registration vector(Containing only registered persons).
I am knot sure about this->
register_person(person & registered)? needs to recieve the
address of a specified(index) person object.
Help me
Education begins a gentleman,
conversation completes him
|
|
|
|
|
If your prototype for register_person is as you stated "register_person(person & registered", then all you really need to do is do "registered.push_back(®istered)". If you are uncertain of the number of persons, you should be going to the heap for allocation. Then you should be doing "news" on the Person objects and thus your prototype for register_person should be "register_person(person * registered)". You would then just need to do "registered.push_back(person)".
|
|
|
|
|
I’m developing a program that uses and depends on a “bought” dll. Everything worked until I got a new version of the dll and tries to use that one with it’s new shipping api.
It seams like, despite I run:
regsvr32 –u MyDll.dll
and then the new dll with the same name
regsvr32 MyDll.dll
the new dll can’t get used at runtime.
All tips are welcomed!!!
...and justice for all
APe
|
|
|
|
|
d00_ape wrote:
the new dll can’t get used at runtime.
This is too vague to be able to offer any assistance on. What do you mean by it can't get used?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
can’t get used at runtime
It crashes, when the program (should) call the dll
It actualy work on my developing cpu, so it's not wrong on the new dll.
Thanks
...and justice for all
APe
|
|
|
|
|
d00_ape wrote:
It crashes, when the program (should) call the dll
Technically, DLLs don't get called. They get loaded into the address space of an application, and then exported functions get called. So, is it crashing on the LoadLibrary() or GetProcAddress() call? If neither of these functions are being used, are you implicitly linking instead.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I run:
#import "MyDll.dll"
and here comes the faliure:
if( SUCCEEDED( hres = m_IPtr.CreateInstance("MyDll.Stuff") ) )
...and justice for all
APe
|
|
|
|