|
|
|
Hi
thanx for your information
Regards
KK
|
|
|
|
|
Hello all.
I am currently working on an application which requires to add new fonts in Fonts folder in Windows directory. I am copying the new fonts in the Fonts folder programatically. According to my knowledge I need to open and then close the Fonts folder to Register the newly added fonts with OS.
To register these fonts I am opening the Fonts folder from my application by using following code snippet
STARTUPINFO si;
PROCESS_INFORMATION pi;
LPTSTR szCmdline=_tcsdup(TEXT("C:\\WINDOWS\\explorer.exe c:\\windows\\fonts"));
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if(!CreateProcess( NULL,szCmdline,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi ))
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
I just have to wait for say 2 secons after opening the Fonts folder to register new fonts. So after opening the folder I am using following code to wait for 2 secs and close the child process and thus the Fonts foloder that I have opened through that child process.
HANDLE handle = pi.hProcess;
Sleep(2000);
int i = ::TerminateProcess(handle,0);
if (0 == i)
{
DWORD err = GetLastError();
}
While debugging I found that the TerminateProcess() function fails and GetLastError() returns value 5.
Is there something that I am not doing properly?
Why the TerminateProcess() is failing?
Please guide me.
Rakesh
|
|
|
|
|
error 5 is "access denied"
Has the process already terminated by itself?
Suggestion:
Try adding GetExitCodeProcess() to the code before TerminateProcess() to check
cheers,
Neil
|
|
|
|
|
check this
<br />
CWnd *pWnd=FindWindow(0,"Fonts");<br />
pWnd->PostMessage(WM_CLOSE);<br />
whitesky
|
|
|
|
|
Thankyou very much....
Such a nice and effective way you have suggested.
It worked as per my requirement..
Thanks again.
Rakesh
|
|
|
|
|
Hey but there is one issue.
If I change the settings from Control pannel
1. Not to Display the full path in title bar
2. To Display the full path in title bar
then the proposed solution doesn't work properly. I need to change the Text from
FindWindow(0,"C:\\Windows\\Fonts)
to
FindWindow(0,"Fonts")
Is there any solution for this ? Please help.
Thanks
Rakesh
|
|
|
|
|
You need to title from window for get one handle to window or CWnd now whats problem
whitesky
|
|
|
|
|
How We Add Popup to listbox Items .when we right click on any listbox item we should get a popup. i tried this but i am unable to get popups in listbox.
please tell me, urgent.
thank you.
vsn
|
|
|
|
|
I gave you a link yesterday. What is the problem with that?
See Here[^]
Oh! I misunderstood it for a tooltip
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 5:44 Saturday 1st July, 2006
|
|
|
|
|
no man i need popup to the listbox items
vsn
|
|
|
|
|
Derive a class from CListBox(CMyList)and override the OnContextMenu function.
Create a menu in the resource editor as ID_POPUP
Add items and add handlers to those menu items.
IN the OnContextMenu Add the following lines of code
CMenu* myMenu=new CMenu();
myMenu->LoadMenu( ID_POPUP );
myMenu->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this );
When you declare the variable for CListBox change it to CMyList and add the header file (MyList.h where you declare the variable in the header file)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 7:35 Saturday 1st July, 2006
|
|
|
|
|
i am getting an error that is setmenuinfo is not a member of menus
vsn
-- modified at 7:34 Saturday 1st July, 2006
|
|
|
|
|
ah. That was a typo mistake(Forgot to delete it). I have deleted the line in my post. You can anyhow do without it for now. For your general information menuinfo was of type MENUINFO
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
override the OnContextMenu function.?
i worte all the code u have given in Myclist::ContextMenu.
but where we notice to call this context menu.
vsn
|
|
|
|
|
You don't need to call the OnContextMenu function.
It is called by the framework when the user has clicked the right mouse button (right clicked) in the window.(from MSDN)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Cross check that you have inherited a class from list box and then overridden the OnContextMenu function over there.Do not forget to change the type of the variable to CMyList.It works.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
overridden the OnContextMenu function over there?
|
|
|
|
|
if you have a derived CListBox you can declare OnContextMenu in this class
and see this
void CMyList::OnContextMenu(CWnd* pWnd, CPoint point)
{
HMENU hmenu,hmenuPopup;
hmenu = LoadMenu(AfxGetApp()->m_hInstance,(LPCTSTR) IDR_MENU1);
hmenuPopup = GetSubMenu(hmenu, 0);
TrackPopupMenu(hmenuPopup, TPM_LEFTALIGN | TPM_LEFTBUTTON,
point.x,point.y, 0,m_hWnd, NULL);
DestroyMenu(hmenu);
}
</code>
whitesky
|
|
|
|
|
Hi All,
I need to develop an Add In for Internet Explorer.
Can anyone help me on how I should proceed any documents in net that are suggested to read.
Thanks,
Arun.
Arun.
|
|
|
|
|
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I want to write a fax server program which can handle faxes with modem device.
Is there any one who knows about such dll or library.
I see some examples but they were in OCX format and I can not use them in VC++ , do you know a dll program for this purpose.
Regards
Mahdi
|
|
|
|
|
m_monhi wrote: I see some examples but they were in OCX format and I can not use them in VC++
why?
Ocx can be used in vc++
nave
|
|
|
|