|
There is always the CRT function _splitpath.
onwards and upwards...
|
|
|
|
|
thanks guys, but i still need to know the best way to kill the process
|
|
|
|
|
Hello all gurus..
I have a program that takes file name and send it to printer.
The program uses powerpoint, ms word, ms excel automation to print all powerpoint files, doc files, and excel files.
The program runs perfectly right before I change the setting of the project.
I changed the project setting as followed,
<br />
c++ -> preprocessor -> WIN32;_WINDOWS;_DEBUG,_UNICODE, UNICODE, _WIN32_WINNT=0X0400;<br />
c++ -> Struct Member Alignment -> 1 Byte (/Zp1)<br />
link -> Advance -> Entry Point -> wWinMainCRTStartup<br />
Before I print any file, I opened all three powerpoint, ms word and ms excel application. And then close all three application after all files get printed.
here the code how I open and close three applications.
<br />
void myApp::OpenApps(bool &open)<br />
{<br />
CoInitialize(NULL);<br />
if(!app.CreateDispatch(L"Excel.Application"))<br />
{<br />
AfxMessageBox(L"Could not create Excel Application Object.");<br />
open = false;<br />
}<br />
else<br />
{<br />
app.put_Visible(TRUE);
app.put_WindowState(2);
app.put_UserControl(TRUE);
<br />
lpDisp = app.get_Workbooks();
ASSERT (lpDisp);<br />
books.AttachDispatch(lpDisp);
}<br />
if(!mswApp.CreateDispatch(L"Word.Application"))<br />
{<br />
open = false; <br />
}<br />
else <br />
{ <br />
mswApp.put_Visible(TRUE);<br />
mswApp.put_WindowState(2);
mswDocs = mswApp.get_Documents();<br />
<br />
}<br />
if(!pptApp.CreateDispatch (L"Powerpoint.Application"))<br />
{<br />
open = false;<br />
}<br />
else<br />
{ <br />
pptApp.put_Visible(1);<br />
pptApp.put_WindowState(2); <br />
}<br />
}<br />
void myApp::CloseApps(void)<br />
{ <br />
app.Quit();<br />
app.ReleaseDispatch();<br />
app=NULL;<br />
<br />
mswApp.Quit(covFalse,covOptional,covOptional); <br />
mswDocs.ReleaseDispatch();<br />
mswApp.ReleaseDispatch(); <br />
mswApp = NULL;<br />
<br />
pptApp.Quit(); <br />
pptApp.ReleaseDispatch ();<br />
<br />
pptApp = NULL;<br />
<br />
CoUninitialize();
}<br />
<br />
Let's only talk about printing MS Word file.
After the project setting got changed, only the first document file get printed and but it has error when opening the next document. here the code to print the word document files.
<br />
void CClientJob::PrintWithMsWord(CString fname)<br />
{<br />
VARIANT tv;<br />
tv.vt = VT_BSTR;<br />
tv.bstrVal = fname.AllocSysString();
CDocument0 doc;<br />
<br />
doc = mswDocs.Open(&tv,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional);<br />
SetMSWordPageSetup(doc);<br />
doc.PrintOut(covFalse,covOptional,covOptional,covOptional,covOptional,covOptional,<br />
covOptional, covOptional,covOptional,covOptional,covOptional,covOptional,<br />
covOptional,covOptional,covOptional,covOptional,covOptional,covOptional);<br />
doc.Close(covFalse,covOptional,covOptional);<br />
<br />
mswDocs = NULL;<br />
}
I know this is something to do with my project setting coz it has no problem before.
I need to have that setting also. I can't change the setting and need to print office files too.
Am I missing any other setting?
thank you
|
|
|
|
|
I don't think it is due to your setting that causes your problem.
Try to place in the exception catch in your codes and see if it helps. It always better to have these try .. catch around.
try
{
..
}
catch(_com_error e)
{
TRACE(_T("Error: %08x %s\n"), e.Error(), e.ErrorMessage());
_bstr_t bstrDesc = e.Description();
if(bstrDesc.length() > 0)
{
TRACE(_T("Description: %s\n"), static_cast<LPTSTR>(desc));
}
}
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I'm writing a 3D modeling app using MFC MDI framework. I'm trying to get a dockable dialog bar with a Treeview control to display a list of objects within the project's workspace, but I can't seem to access the treeview for initialization or manipulation. I've created a dialog template in the resource editor with a treeview control in the dialog. I then created a class for the dialog box/bar, and assigned a variable to the treecontrol (m_tree). I then declared the entire dialogbar in CMainFrame. The dialog bar loads, and is dockable, but I can't seem to initialize it anywhere. I've tried initilizing it in the Dialog class OnCreate, and OnInitDialog, but it has no effect. I also tried to apply afx_msg overrides to the CMainFrame class, but I get an error saying I can't call a static function (something along those lines). Does anyone know how I can get this thing running, or know of any good articles/tutorials that deal with a dockable treeview in an MDI application?
|
|
|
|
|
|
I am using VisualC++ to write a multimedia program using COM. I get link errors when I compile my program stating that CLSID_FilterGraph and IID_IGraphBuilder are unresolved externals. Here is the code they appear in:
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder,
(void**)&pBuilder);
The code is straighforward and the CLSID_FilterGraph can even be found using search in the file uuids.h. When I include it the link errors remain. I made sure to include DirectX headers and libraries in the link paths for VisualC++. Here is a list of all of the headers and defines I have included:
#define _WIN32_DCOM
#include <dshow.h>
#include<uuids.h>
#include <commdlg.h>
#include <commctrl.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#ifndef GetWindowLongPtr
#define GetWindowLongPtrA GetWindowLongA
#define GetWindowLongPtrW GetWindowLongW
#ifdef UNICODE
#define GetWindowLongPtr GetWindowLongPtrW
#else
#define GetWindowLongPtr GetWindowLongPtrA
#endif // !UNICODE
#endif // !GetWindowLongPtr
#ifndef SetWindowLongPtr
#define SetWindowLongPtrA SetWindowLongA
#define SetWindowLongPtrW SetWindowLongW
#ifdef UNICODE
#define SetWindowLongPtr SetWindowLongPtrW
#else
#define SetWindowLongPtr SetWindowLongPtrA
#endif // !UNICODE
#endif // !SetWindowLongPtr
#ifndef GWLP_USERDATA
#define GWLP_USERDATA (-21)
#endif
I realize that some of these defines and included are irrelavent. I copied everything from the example files (which worked) in the way of headers and I thought I should show you what I had tried. I've been staring at this problem for a day now and any help would be greatly appreciated.
Thanks
Jeff
|
|
|
|
|
Hello!.. this code:
<br />
#include <list><br />
<br />
struct ElementLista {<br />
string jid;<br />
string nombre;<br />
string subscripcion;<br />
} elem;<br />
<br />
typedef std::list<ElementLista> Lista;<br />
gives me the following errors:
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest
any ideas? thanks!
|
|
|
|
|
#include <list>
#include <string>
struct ElementLista {
std::string jid;
std::string nombre;
std::string subscripcion;
} ;
typedef std::list< ElementLista> Lista;
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
sorry, i get the same errors.
i' using vc++6.0
|
|
|
|
|
That makes sense. I compiled in VC6 before posting that code so it will compile.
I tried many variations on the code you posted and could not reproduce the compiler errors you posted. It is likely your error is in another place in your code.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
damn
it's the only place i use stl.
if i comment that out, everything else works
|
|
|
|
|
Ok, went back and looked at your original post more closely. THIS_FILE provides a clue so I put my code in a .cpp file and produced the errors you reported.
Then put the declarations back into a header file and instantiate a Lista variable in the .cpp file. No compile errors.
Give it a try.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
i need the 'Lista' as an atribute of a class.
#include <list>
#include <string>
struct ElementLista {
std::string jid;
std::string nombre;
std::string subscripcion;
} elem;
typedef std::list< ElementLista> Lista;
class CProtocolo
{
public:
Lista ListaContactos;
..
.
.
};
|
|
|
|
|
struct ElementLista {
std::string jid;
std::string nombre;
std::string subscripcion;
} elem;
That declares a variable named "elem" of type ElementLista at file scope which i don't think you want. Plus it can cause compile errors due to redefinition of the variable.
Using the type for a class member variable is fine.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
#include < list > before the MFC macros(*) kick in.
(*)
<small>#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif</small>
---
"Man will never be free until the last king is strangled with the entrails of the last priest". -- Denis Diderot
|
|
|
|
|
Hi there,
When I call the convertString function I get the 2 of the same errors on the same line: missing ';' before '.' I can't seem to find a problem with it. Can someone help me?
Thanks!
char temp2[6];
UINT temp;
temp = 129;
CRex.convertString(temp2, temp); //error on this line
/**********************************************************
void CRex::convertString(char *value, unsigned int num)
{
char convert[8] = {'0', '1', '2', '3', '4', '5', '6', '7'};
value[0] = convert[num >> 12 & 0x7];
value[1] = convert[num >> 9 & 0x7];
value[2] = convert[num >> 6 & 0x7];
value[3] = convert[num >> 3 & 0x7];
value[4] = convert[num & 0x7];
value[5] = 0;
}
|
|
|
|
|
CRex is a type of object, but not an object itself. How about:
char temp2[6];
CRex cr;
UINT temp;
temp = 129;
cr.convertString(temp2, temp);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
since there is no instance data used in convertString you could make it a static member of CRex...
class CRex{
public:
static void convertString(char* value, unsigned int num);
};
then use it like this...
CRex::convertString( temp2, temp);
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
char convert[8] is not large enough to hold your string.
Try
char convert[9] = {'0', '1', '2', '3', '4', '5', '6', '7'};
or
char convert[] = {"01234567"};
|
|
|
|
|
Your syntax is wrong. You need to make convertString a static member of CRex and call it like CRex::convertString . But why is convertString a member in the first place? IMO it's worth answering that question.
Paul
|
|
|
|
|
Thank you all for your quick responses! I followed David Crow's advice and it worked. Thank you again for the support. This is definitely the best message board I ever came across!
|
|
|
|
|
Hi.
I want to enumerate all of the processes that are running on a particular desktop. Enumerating all processes isnt the problem, its the filtering of them that is causing me trouble.
The desktop a process is to run on is specified in the STARTINFO passed to CreateProcess, however, as far as I can see, this is the only place where the desktop is specified, and the only function I can find to retrieve this information is GetStartupInfo, which will only return the STARTUPINFO structure for the calling process.
Any ideas?
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|
So what exactly is your question? If you are not wanting all of the processes that CreateToolhelp32Snapshot() provides a list of, what are you wanting to filter on?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The desktop they are a part of. One of the memebers of STARTINFO is lpDesktop. If you create a desktop called CP, using CreateDesktop, then set lpDesktop to "CP", when using CreateProcess, the process runs in the CP desktop, so, if your not viewing the CP desktop, you wouldnt see the applications window appear (if it has one).
What I can get, is handles to all of the windows in running on the desktop - maybe I can use that to find the processes, and kill them.
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|