|
Hi, folks,
I got a question about getting the full path of WordPad.exe.
How can I get the full path of WordPad.exe ?
I mean, some system uses something like this:
C:\\Program Files\\Accessories\\WordPad.exe
while on Windows XP, it might be:
C:\\Program Files\\Windows NT\\Accessories\\WordPad.exe
So, any one help me ?
And, I want to paunch WordPad.exe and open my document (something like *.txt
or *.doc), I use CreateProcess to do this, but, WordPad.exe is launched, but my document is NOT opened ?
CreateProcess( "C:\\Program Files\\Accessories\\WordPad.exe", "D:\\myDoc.txt", NULL, NULL,FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo ))
Could any one tell me what's the right way to open my document with wordpad.exe ?
Any response would be appreciated. Thanks in advance ! ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
you can find the path of wordpad in the registry by getting the key in the run keys
|
|
|
|
|
I use this code in a 'while' loop:
FILE *afile;
int numwritten;
afile = fopen( strpath, "r+" );
char list1[1];
list1[0] = (char)('a');
list1[1] = (char)('a');
numwritten = fwrite( list1 , sizeof( char ), 1, afile );
It does what I want but after while loop ends this runtime error occur:
Run-Time Check Failure #2 - Stack around the variable 'list1' was corrupted.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You are only allocating one character, while accessing two. Use:
char list1[2];
You will also need to close the file after writing to it.
|
|
|
|
|
Niklas Lindquist wrote:
You are only allocating one character, while accessing two. Use:
Yes,that was the problem.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
My problem is that I want to place the statusbar between the the titlebar and the menu.
Please, help me!!!!
CSZX
|
|
|
|
|
Struct aligment is decided at compile-time. Fine.
But some functions, like GetVersionEx and IContextMenu::InvokeCommand uses the size member of the input structure to decide which struct is passed. They must check if the cbSize member is set to sizeof(...). Since that code is compiled by ms, they might have different struct aligment settings => different return value from sizeof. How does this work? Isn't there a potential bug somewhere?
A second example. Check the structure FILEGROUPDESCIPTOR. It has a serie of FILEDESCRIPTOR structures as members. How can one be convinced that my code and the ole libraries agrees on where each struct starts?
|
|
|
|
|
Anonymous wrote:
They must check if the cbSize member is set to sizeof(...). Since that code is compiled by ms, they might have different struct aligment settings => different return value from sizeof. How does this work? Isn't there a potential bug somewhere?
The cbSize fields do not set the struct alignment, it is simply a variable that indicates how large the structure is. By testing how large the structure is, an application can tell which version of the structure is being used. Some of the structures in the newer Win32 OS have more fields to add detail to the object or structure that is being described. Any of the API functions that use these structures have conditionals in place to check the size of the structure, and determine how it can be used based on the size of teh struct.
Anonymous wrote:
Check the structure FILEGROUPDESCIPTOR. It has a serie of FILEDESCRIPTOR structures as members. How can one be convinced that my code and the ole libraries agrees on where each struct starts?
This structure is just one size for all operating systems:
typedef struct _FILEGROUPDESCRIPTOR {
UINT cItems;
FILEDESCRIPTOR fgd[1];
} FILEGROUPDESCRIPTOR, * LPFILEGROUPDESCRIPTOR;
The fgd field provides a static anchor to hold an array of FILEDESCRIPTOR objects, which is also only one size. The cItems field in this structure indicates how large the buffer is pointed to by fgd. The entire size of the buffer is sizeof<FILEDESCRIPTOR> * cItems .
If you were to allocate memory for this structure, this is one way that you could do it:
FILEGROUPDESCRIPTOR *pfgd;
pfgd = (FILEGROUPDESCRIPTOR*) new BYTE[sizeof(FILEGROUPDESCRIPTOR + (5 * sizeof(FILEDESCRIPTOR))];
if (!pfgd)
{
...
}
pfgd->fgd[0].dwFlags = 0;
...
pfgd->fgd[1].dwFlags = 0;
...
When ole or anyone else wants to access this structure they will access it in the exact same way.
|
|
|
|
|
The system simply assumes you're using the default alignment and pack size for Win32 (check MSDN article Structure alignment.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Okay, that makes sense.
Sorry Kilowatt, but you didn't understand the question. The size of a structure changes with byte aligment.
Try for example.
struct Test
{
char a;
};
sizeof(Test) will change with different byte aligment.
|
|
|
|
|
Hi, I just found this article "Add Windows XP Theme Style to your current projects" here on Code Project. It makes my dialogs look XP-stylish under XP.
Now the problem: I use ownerdraw controls too... which I want to look different when running under XP (e.g. make them looks more XP like). Is there an easy way to achieve this (e.g. detect XP on runtime), any additional hints, handy things to know?
Thx, Moak
|
|
|
|
|
hm, seams to be a non-trivial question.
|
|
|
|
|
I wanna see some BYTE type in CString,for example for int I use this:
str.Format("%d",integer);
Now what about BYTE?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
str.Format("%d",(int)byte) should do.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Joaquin:
About that VIRUS,I found the trick.I wrote some search code for finding Doc files and for each finding I used this code:
FILE *afile;
afile = fopen( str, "r+" );
char list2[4]={0,0,0,0};
fread( list2 , sizeof( char ), 4, afile );
CString str1=(CString )(list2);
AfxMessageBox(str1);
I found out most of .doc start with:
'ÐÏ' or '{\rt' charachters.
Now if you change one or two first charachter with fwrite() see what happend to your file.The file size or icon or ... does not change but after MSOffice open it does not shown in correct format,what's your opinion about it?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You are a bad boy Mazdak Use the trick to do the good not the evil
I think this would work. If you want to keep the information, you might add the characters changed at the end of the file --this will change the file size, though.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
You are a bad boy Mazdak Use the trick to do the good not the evil
Ok Joaquín,I'll do as you said. But Information Is Power.I keep this trick in my mind,One day maybe I use it against my enemies.
Joaquín M López Muñoz wrote:
If you want to keep the information, you might add the characters changed at the end of the file --this will change the file size, though.
I've not test it yet,but I think for keep information only I need to change the first character to the first one(Ð),because the first charachter is constant in all .doc files.This is better than add it to the end,so I can keep both information anf file size.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
as title
I'm amumu, and you?
|
|
|
|
|
Huh?
Do you mean how to add a DeleteItem notification handler, or what to do when you get it?
To add the notification, you need to add
afx_msg void OnDeleteTreeItem(NMHDR *pNMHDR, LRESULT *pResult);
to your header, then add:
ON_NOTIFY(TVN_DELETEITEM, IDC_MY_TREE_CTRL, OnDeleteTreeItem)
to your message map. Finally, add the handler to your .cpp file:
void CMyClass::OnDeleteTreeItem(NMHDR *pNMHDR, LRESULT *pResult)
{
NMTREEVIEW *pTreeNotify = (NMTREEVIEW *)pNMHDR;
}
As to what you do in the handler, that's up to you...
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Thanks, I got it
I'm amumu, and you?
|
|
|
|
|
Ive looked through here and the general concensus is that it is not possible to have an application with a msg loop but no window. Just wanted to see if anyone knows of a way around this.
Havent had much luck with SetWindowsHookEx If anyone knows where I can look for some examples using this function Id appreciate it.
Im just experimenting .. nothing particular. So far Ive been able to obtain a DC for the display and draw on it but I need to be able to process mouse input.
Id rather find a way to do so with out resorting to hiding windows..
Thats why Im thinking using SetWindowsHookEx in a dll might be the answer.
Any thoughts?
|
|
|
|
|
Ive looked through here and the general concensus is that it is not possible to have an application with a msg loop but no window.
On the contrary, it is perfectly possible to have an app with a message loop and no windows at all. The following is an example including a Windows timer that terminates the app in 5 seconds:
#include <windows.h>
static UINT ending_timer=0;
static VOID CALLBACK ending_timer_proc(HWND,UINT,UINT,DWORD)
{
PostQuitMessage(0);
}
int main(void)
{
MSG msg;
PeekMessage(&msg,NULL,0,0,PM_NOREMOVE);
ending_timer=SetTimer(0,0,5000,(TIMERPROC)ending_timer_proc);
while(GetMessage(&msg,NULL,0,0)!=0){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
KillTimer(0,ending_timer);
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
Is there a way to disable the auto status bar update on pane 1? For example, you will see "Ready" in the first pane of the status bar when the program first starts (single-document using AppWizard). I need to use pane 1 of the status bar for something. I would like to disable the auto status bar update (system update).
Thanks,
Kuphryn
|
|
|
|
|
Hi.
I am using AppWizard single-document type setup. I need to get the rectange of the ChildView. All I am trying to do is change the background color of the ChildView. So ineed to get the exact size and location of the ChildView related to the MainFrame. I tried using this:
-----
CWnd *pWnd = AfxGetMainWnd();
CRect rectCView;
pWnd->get(rectCView);
CBrush *pOldBrush, newBrush(RGB(0, 0, 0));
CDC *pDC = pWnd->GetDC();
pOldBrush = pDC->SelectObject(&newBrush);
pDC->Rectangle(rectCView);
pDC->SelectObject(pOldBrush);
pWnd->ReleaseDC(pDC);
-----
The problem with the code segment above is that it repaint everything inside the MainFrame including the toolbar and statusbar. I would like it to paint the ChildView.
Thanks,
Kuphryn
|
|
|
|
|
Paint it inside the Child View.
That would be much easier and correct,
ensuring repainting of the child view
will retain the bkcolor.
|
|
|
|
|