|
How could I get the path of a APP.EXE ??
I need to open a Site with Internet Explorer browser. I have used the GetModuleFileName function, but I don't have the HMODULE parameter (to get HMODULE, the GetModuleHandle function also doesn't work).
Any idea ??
Thanks,
Cris.
|
|
|
|
|
|
Hello There!
If the app was put on your computer with an installer you don't need the path because it is registered in the registery automatically. You can just provide the name of the executable in ShellExecute(..) and it will launch the app.
However if you insist on getting the path use this:
char szRegBuf[200];
DWORD pcbData=199;
if(!::SHGetValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\TheExecutable.exe","Path",(LPDWORD)REG_NONE,szRegBuf,&pcbData))
{
AfxMessageBox("Successfuly located TheExecutable.exe path in the registry");
}
|
|
|
|
|
Ok, and abount the SHGetValue function ?? Where it is declared ??
[]'s
|
|
|
|
|
Hi Cris,
It is declared in Shlwapi.h.
Or you can use some other Registry access function if you want. I have the MSDN info for you if you wish. But once again you really don't need the path if you use ShellExecute(..) on an installed application.
Art
///////////////
From MSDN info
///////////////
SHGetValue
Retrieves a registry value.
DWORD SHGetValue(
HKEY hkey,
LPCTSTR pszSubKey,
LPCTSTR pszValue,
LPDWORD pdwType,
LPVOID pvData,
LPDWORD pcbData
);
Parameters
hkey
Handle to the currently open key, or any of the following predefined values: HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_DYN_DATA (Windows 95 only)
HKEY_LOCAL_MACHINE
HKEY_PERFORMANCE_DATA (Windows NT only)
HKEY_USERS
pszSubKey
Address of a null-terminated string that specifies the name of the subkey from which to retrieve the value.
pszValue
Address of the value.
pdwType
Type of value. For more information, see Registry Data Types.
pvData
Address of the destination data buffer.
pcbData
Size of the destination data buffer.
Return Values
Returns ERROR_SUCCESS if successful, or a nonzero error code defined in Winerror.h otherwise. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to retrieve a generic description of the error.
Remarks
Note If your application must set/retrieve a series of values in the same key, it is better to open the key once and set/retrieve the values with the regular Microsoft® Win32® registry functions rather than use this function repeatedly.
Requirements
Version 4.71 and later of Shlwapi.dll
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later).
Windows 95/98/Me: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later).
Header: Declared in Shlwapi.h.
Import Library: Shlwapi.lib.
|
|
|
|
|
Is it possible to change the background color of a menu from white to gray eg. RGB(222, 222, 222) without having an owner drawn menu?
|
|
|
|
|
georgiek50 wrote:
Is it possible to change the background color of a menu from white to gray eg. RGB(222, 222, 222) without having an owner drawn menu?
I doubt it. You could try temporarilly changing the control panel colors, but this would effect all aplications and menus.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
You can do that with SetMenuInfo() and set a new background brush - only works on 98+ and 2000+ however.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"Which comes first, the bug or the stress?" -- Chris Maunder
|
|
|
|
|
Thats quite strange that it wouldn't work with XP. I tried it anyways but even though the class members where showing up when I was filling in my MENUINFO struct the program failed to compile because MENUINFO was not recognized...Does this have anything to do with me running XP (I doubt it, I think...) and windows.h is included.
Regardless, what are some better alternatives to take care of XP Windows and below?
|
|
|
|
|
It does work with XP. I tried it on my XP machine and it works beautifully.
Are you declaring your CBrush object as a class member so it doesn't go out of scope?
Art
/////////////////
From MSDN
/////////////////
The MENUINFO structure contains information about a menu.
typedef struct tagMENUINFO {
DWORD cbSize;
DWORD fMask;
DWORD dwStyle;
UINT cyMax;
HBRUSH hbrBack;
DWORD dwContextHelpID;
ULONG_PTR dwMenuData;
} MENUINFO, FAR *LPMENUINFO;
typedef MENUINFO CONST FAR *LPCMENUINFO;
Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Winuser.h; include Windows.h.
|
|
|
|
|
Actually when I declare a MENUINFO struct eg. MENUINFO mi and then proceed to iniatilize the members of MENUINFO they are coming up on the classwizard (or whatever it is called). When I try to compile it though it does not recognize MENUINFO or SetMenuItem. I have included Windows.h. Are there any other headers necessary for it to work? (I am using Visual C++ 6.0)
|
|
|
|
|
I am using VC++ 7.0 but that shouldn't matter here.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
CMenu *pMainMenu=GetMenu();
if(pMainMenu == NULL)
return...
CBitmap bm1;
bm1.LoadBitmap(IDB_MENU); //I made a small gradient bitmap (IDB_MENU)
m_MenuBrush.CreatePatternBrush(&bm1); //m_MenuBrush is a CBrush
MENUINFO mi;
mi.cbSize = sizeof(MENUINFO);
mi.fMask = MIM_BACKGROUND;
mi.hbrBack =m_MenuBrush;
CMenu* pMenuSub0 = pMainMenu->GetSubMenu(0); //File
CMenu* pMenuSub1 = pMainMenu->GetSubMenu(1); //Edit
CMenu* pMenuSub2 = pMainMenu->GetSubMenu(2); //View
CMenu* pMenuSub3 = pMainMenu->GetSubMenu(3); //About
// TODO: Should do some error checks for NULL pointers...
pMenuSub0->SetMenuInfo(&mi);
pMenuSub1->SetMenuInfo(&mi);
pMenuSub2->SetMenuInfo(&mi);
pMenuSub3->SetMenuInfo(&mi);
}
Art
|
|
|
|
|
Netmeisters,
I need to write an SSL client in C++ for desktop Windows. I've read Rescorla's excellent SSL book and done a fair amount of SSL programming, using C and openSSL for Linux, eVC++ for the Pocket PC, and java. Although the Pocket PC project might seem similar, apparently WinCE provides quite different SSL facilities than desktop Windows. I haven't found any books on the subject (Rescorla explicitly avoids Windows) and I haven't found much on msdn.
So I'd really appreciate a pointer to some documentation that might help me get started. I'd like to know if desktop Windows provides facilities for SSL, and if so, how to use them. (If not, I'll just use openSSL.)
Thanks very much,
Matthew Fleming
mgf@mcw.edu
|
|
|
|
|
|
I have an array of property pages and I change their caption/title dynamically...
This works in the commented way, but when I try to do it using the non commented way, it crashes... (I'd like to know why)...
PREMISSES:
THE CASE THAT WORKS:
I have an array of property pages.
I have an array of titles.
Those two are members of the property sheet class.
THE CASE THAT DON'T WORKS:
I have an array of property pages.
I have one CString var declared inside the cosntructor of the property sheet class that will be used to store all the titles in the property pages...
THE CODE
{
...
this->m_ArrPPDlgParametritzacions[iNumPPags].m_psp.dwFlags |= PSP_USETITLE; <code>
this->m_ArrPPDlgParametritzacions[iNumPPags].m_psp.dwFlags &= ~PSP_HASHELP; <code>
csTitolPPag = ((char *)pxmlNode->attributes->getNamedItem("EtiquetaDescriptiva")->Gettext()); <code>
this->m_ArrPPDlgParametritzacions[iNumPPags].m_psp.pszTitle = csTitolPPag;
this->AddPage(&m_ArrPPDlgParametritzacions[iNumPPags]); <code>
iNumPPags++; <code>
} Any idea?
It's not a vital thing, I can live having an array of CStrings using memory, but it would be better to be able to do it without the array...
thank you in advance...
|
|
|
|
|
I would imagine that csTitolPPag is just a local string variable. The problem you are having is that
this->m_ArrPPDlgParametritzacions[iNumPPags].m_psp.pszTitle
is nothing more than a pointer to a character string. So when csTitolPPag goes out of scope, the string is deleted and thus pszTitle now points to trash.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
This is what I think, but is there any way to do it assigning the content, and not the direction?
Thank you in advance...
|
|
|
|
|
You would have to find the length of the string you are copying, then allocate a character array on the heap with length + 1 size, do a memset to set this new memory to 0, do a memcpy from the CString's psz pointer to this new memory, then set the array psz to be the new pointer. That way the memory will always be there in the array psz. Just be sure to do a delete [] on this array psz when this array is no longer needed, or will get a memory leak. (The memset to 0 may not be needed, it may be done automatically when call new.)
David Spain
|
|
|
|
|
Hi
How to load a resource on his name (for example IDB_BITMAP1), but it is not known ID. And whether it is possible?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
IDB_WHATEVER is a mnemonic for a numerical ID, not a name. The mnemonic is #define'ed in a header file named resource.h by default.
Maybe you have just forgotten to #include resource.h?
Bernd
|
|
|
|
|
Do you mean load it as a string name? If you are asking that exclude the MAKEINTRESOURCE parameter, I don't really understand the question though...
|
|
|
|
|
|
|
Cool. Thanks.
|
|
|
|
|
Hi Everyone,
I have an application that has a thread within a thread. When I delete the parent it is suppose to delete the child thread within the destructor. Unforetunately I am running into problems where the memory has already been freed (at least that is what I think has happened) and trying to free the resources are used by the threads.
When I run the application through boundschecker I don't see this problem at all so I think it has to do with some race condition. Is there some documentation on how to properly and effectively control the destruction of threads?
Cheers,
Clint
|
|
|
|