mfc >> detect an executable

by amlt » Tue, 25 Jan 2005 00:45:11 GMT

Hi,
I need to find out whether a program is installed on my computer. Right now
I used CFileFind to search the exe recursively in the Program Files folder.
Is there any better way to do this in MFC?

Thanks a lot.
Jim


mfc >> detect an executable

by David Lowndes » Tue, 25 Jan 2005 00:59:16 GMT


>I need to find out whether a program is installed on my computer. Right now

Jim,

There's nothing to say the program is installed beneath Program Files
so that may well not suffice.

You need to tell us some more about your problem.

Dave



mfc >> detect an executable

by amlt » Tue, 25 Jan 2005 01:15:05 GMT

For example, I need to find whether I have winword.exe on my computer.
Right now, we assume it is installed in Program Files folder. we can search
the whole computer if we don't have this assumption. I am asking is there a
better way to find an exe on my computer?
Thanks a lot.
Jim





detect an executable

by David Lowndes » Tue, 25 Jan 2005 01:35:08 GMT

>For example, I need to find whether I have winword.exe on my computer.

Sorry to sound pedantic, but why? What's the real issue? Why do you
need to know it's there? Does it matter which version of winword is
available?

You could have winword.exe on the computer, but that doesn't mean it's
installed and functional.


A recursive search using CFileFind (FindFirstFile, etc) is the way to
look for a file.

Dave


detect an executable

by Fredrik Wahlgren » Tue, 25 Jan 2005 07:23:45 GMT




search
a


Try to create an instance of winword using CoCreateInstance.

/Fredrik




detect an executable

by szuchymj » Tue, 25 Jan 2005 07:35:17 GMT

You mean, is there some kind of database that contains only the
installed programs on your computer, that could be searched through
very quickly in comparison to the entire hard disk? I don't know.

If it does exist, it would not contain all applications, only the ones
in the Windows Add/Remove programs dialog. Is this similar to what you
had in mind?



detect an executable

by Fredrik Wahlgren » Tue, 25 Jan 2005 07:38:06 GMT





I mean that MS word is an application that can be started from COM. Only
some applications can be started this way. If it can, then it must be
installed. They may or may not appear in the Windows Add/Remove programs
dialog

/Fredrik




detect an executable

by uwe.kotyczka » Tue, 25 Jan 2005 19:13:59 GMT

In this special case you can ask the registry if Winword is installed.
All versions of MS Office (at least from Office95) generate a registry
key "Word.Basic" which tells you wheather or not Word is installed.

m_bIsWordInstalled = ProgIDExists(_T("Word.Basic"));

BOOL ProgIDExists(LPCTSTR szProgID)
{
BOOL bRet = FALSE;
HKEY hkey;

if (RegOpenKeyEx(HKEY_CLASSES_ROOT, szProgID, 0, KEY_READ, &hkey) ==
ERROR_SUCCESS)
{
bRet = TRUE;
RegCloseKey(hkey);
}

return bRet;
}

In a program of mine I save the contents of a RichEdit control to a
RichText file.
This usually contains some graphics and therefore the RichText file is
rather large.
However, converting it to .doc by Winword decreases the file size to
(about) 10% of
the original file size.
So my program first asks if Winword is installed (code above). If so, I
use Winword
as a server to convert the .rtf to .doc. Works like a charme.

HTH



detect an executable

by Jerry Coffin » Wed, 26 Jan 2005 12:42:40 GMT

In article < XXXX@XXXXX.COM >,
XXXX@XXXXX.COM says...

Reasonably speaking, my advice would be to create a file that would
normally be opened by the program you're looking for, and then call
FindExecutable on that file to see if it bears a reasonably strong
resemblance to what you're looking for. This will be a whole lot
faster and probably more accurate than trying to look for the
executable directly.

--
Later,
Jerry.

The universe is a figment of its own imagination.


detect an executable

by Snow » Wed, 26 Jan 2005 18:15:02 GMT

How about reading the registry location
"HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\APPPATHS"?







Similar Threads

1. How to detect an executable file?

In my application, users can upload files and store them in a
database.

I would like to prevent them from uploading executable files. The
question is: How do I detect if it is an executable file?

I am not asking about checking the .exe extension, which is easy, and
unreliable because one can easily rename malicious.exe to
prettygirl.jpg.

If you have used gmail attachment, you would know.

I googled, but cannot find anything helpful.  Your hint is highly
appreciated.

2. How to detect memory leak and detect who causes a memory leak - Windows CE

3. Error: Task executable could not be run. Executable not a valid Win32 application !?

Hallo,

I just tried to compile my application, when I got following error:

-------------------------------------------------------------------------
The specified task executable could not be run. The specified executable 
is not a valid Win32 application.
-------------------------------------------------------------------------

When I click on "Show Error Help", the program searches for 
"MSBuild.ToolTask.CouldNotStartToolExecutable" in the documentation, but 
finds nothing.

Does anybody know what causes this error and how I can get my 
application to build again?


Thanks,
Firona

4. Making an executable - CSharp / C#

5. VS 2005 - Problems deploying C# executable to target

I have tried everything I could find in this and other forums.
I've developed a simple application in VS 2005, but when trying to
deploy it to my device (ARM4VI based, CE6.0) I always get "Unable to
load the CLR error" Checking and unchecking the "deploy the latest
version of .NET compact framework" doesn't seem to help.
I have copied to target and executed "NETCFv2.wce5.armv4i.cab", but
got an error.
Here is the LOG file content:

01/01/2006 12:05:37: Entered Install_Init().
        First Call: Yes
        Previously Installed: No
        Installation folder is: '\Windows'.
01/01/2006 12:05:37: Build 2.0.7045.00 created on Feb 13 2007 at
22:23:41
01/01/2006 12:05:37: Device CPU: 'ARMV4I', 05020000 (84017152)
01/01/2006 12:05:37:  6.00
01/01/2006 12:05:37: AKU string : ''
01/01/2006 12:05:37: OEM info   : 'VR35'
01/01/2006 12:05:37: Our trust level is: 2
01/01/2006 12:05:37: User   LCID: 1033
01/01/2006 12:05:37: System LCID: 1033
01/01/2006 12:05:37: Invoker's command line: '/noui \Windows
\NETCFV2.wce5.armv4i.cab'
01/01/2006 12:05:37: Memory status, K --------------------------
01/01/2006 12:05:37:   Load           : 27
01/01/2006 12:05:37:   Physical       : 55864
01/01/2006 12:05:37:   Physical free  : 41160
01/01/2006 12:05:37:   Virtual        : 1048576
01/01/2006 12:05:37:   Virtual free   : 1047936
01/01/2006 12:05:37: Storage status, K -------------------------
01/01/2006 12:05:37:   Available to us: 49716
01/01/2006 12:05:37:   Total storage  : 55768
01/01/2006 12:05:37:   Available total: 49716
01/01/2006 12:05:37: -------------------------------------------
01/01/2006 12:05:37: About to process registry.
01/01/2006 12:05:37: Created CF registry key OK.
01/01/2006 12:05:37: Looking for upgradeable installations for version
'2.0.7045.00'
01/01/2006 12:05:37: Added new CF version value '2.0.7045.00'.
01/01/2006 12:05:37: CF registry key closed.
01/01/2006 12:05:38: Entered Install_Exit().
        Failed Dirs: 0
        Failed Files: 0
        Failed RegKeys: 0
        Failed RegVals: 0
        Failed Shortcuts: 0
01/01/2006 12:05:38: Memory status, K --------------------------
01/01/2006 12:05:38:   Load           : 27
01/01/2006 12:05:38:   Physical       : 55864
01/01/2006 12:05:38:   Physical free  : 41156
01/01/2006 12:05:38:   Virtual        : 1048576
01/01/2006 12:05:38:   Virtual free   : 1047936
01/01/2006 12:05:38: Storage status, K -------------------------
01/01/2006 12:05:38:   Available to us: 49716
01/01/2006 12:05:38:   Total storage  : 55768
01/01/2006 12:05:38:   Available total: 49716
01/01/2006 12:05:38: -------------------------------------------
01/01/2006 12:05:38: About to verify reference count.
01/01/2006 12:05:38:  6.00
01/01/2006 12:05:38: About to process alternative files.
01/01/2006 12:05:38:  6.00
01/01/2006 12:05:38: Processing alternative file: '\Windows\.NET CF
2.0\cgacutil.exe.-500~-500~ARMV4I'.
01/01/2006 12:05:38: Special file extension: '.-500~-500~ARMV4I'.
01/01/2006 12:05:38: File is intended for OS: -500 to -500, CPU:
ARMV4I
01/01/2006 12:05:38: Device CPU: 'ARMV4I', 05020000 (84017152)
01/01/2006 12:05:38: CPU matches.
01/01/2006 12:05:38: Version MIN ignored.
01/01/2006 12:05:38: Version MAX ignored.
01/01/2006 12:05:38: Querying version of file '\Windows\.NET CF
2.0\cgacutil.exe.-500~-500~ARMV4I'.
01/01/2006 12:05:38: Version determined to be: 2.0.7045.0.
01/01/2006 12:05:38: Get version completed.
01/01/2006 12:05:38: Querying version of file '\Windows
\cgacutil.exe'.
01/01/2006 12:05:38: Version determined to be: 2.0.7045.0.
01/01/2006 12:05:38: Get version completed.
01/01/2006 12:05:38: Suggestion: overwrite.
01/01/2006 12:05:38: Copy file from '\Windows\.NET CF
2.0\cgacutil.exe.-500~-500~ARMV4I' to '\Windows\cgacutil.exe': done.
01/01/2006 12:05:38: Delete file '\Windows\.NET CF
2.0\cgacutil.exe.-500~-500~ARMV4I': done.
01/01/2006 12:05:38: Processing alternative file: '\Windows\.NET CF
2.0\mscoree.dll.-500~-500~ARMV4I'.
01/01/2006 12:05:38: Special file extension: '.-500~-500~ARMV4I'.
01/01/2006 12:05:38: File is intended for OS: -500 to -500, CPU:
ARMV4I
01/01/2006 12:05:38: Device CPU: 'ARMV4I', 05020000 (84017152)
01/01/2006 12:05:38: CPU matches.
01/01/2006 12:05:38: Version MIN ignored.
01/01/2006 12:05:38: Version MAX ignored.
01/01/2006 12:05:38: Querying version of file '\Windows\.NET CF
2.0\mscoree.dll.-500~-500~ARMV4I'.
01/01/2006 12:05:38: Version determined to be: 2.0.7045.0.
01/01/2006 12:05:38: Get version completed.
01/01/2006 12:05:38: Querying version of file '\Windows\mscoree.dll'.
01/01/2006 12:05:38: Version determined to be: 2.0.7045.0.
01/01/2006 12:05:38: Get version completed.
01/01/2006 12:05:38: Suggestion: overwrite.
01/01/2006 12:05:38: Copy file from '\Windows\.NET CF
2.0\mscoree.dll.-500~-500~ARMV4I' to '\Windows\mscoree.dll': done.
01/01/2006 12:05:38: Delete file '\Windows\.NET CF
2.0\mscoree.dll.-500~-500~ARMV4I': done.
01/01/2006 12:05:38: Attempting to remove old files from GAC.
01/01/2006 12:05:38: Delete GAC list file: failure
01/01/2006 12:05:38: Run: '\Windows\cgacutil.exe /silent /refresh ',
error code: 0 (00000000), exit code: -2147483648 (80000000)
01/01/2006 12:05:38: Refreshed GAC.
01/01/2006 12:05:38: About to add files to the GAC.
01/01/2006 12:05:38: GAC list file opened.
01/01/2006 12:05:38: Writing UTF8 signature: done.
01/01/2006 12:05:38: Adding file 'mscorlib.dll': added.
01/01/2006 12:05:38: Adding file 'system.dll': added.
01/01/2006 12:05:38: Adding file 'system.drawing.dll': added.
01/01/2006 12:05:38: Adding file 'system.messaging.dll': added.
01/01/2006 12:05:38: Adding file 'system.web.services.dll': added.
01/01/2006 12:05:38: Adding file 'system.windows.forms.dll': added.
01/01/2006 12:05:38: Adding file 'system.windows.forms.datagrid.dll':
added.
01/01/2006 12:05:38: Adding file 'system.xml.dll': added.
01/01/2006 12:05:38: Adding file 'system.net.irda.dll': added.
01/01/2006 12:05:38: Adding file 'system.data.dll': added.
01/01/2006 12:05:38: Adding file 'microsoft.visualbasic.dll': added.
01/01/2006 12:05:38: Adding file 'microsoft.windowsce.forms.dll':
added.
01/01/2006 12:05:38: Adding file
'Microsoft.WindowsMobile.DirectX.dll': added.
01/01/2006 12:05:38: Adding file 'CustomMarshalers.dll': added.
01/01/2006 12:05:38: Closed list file.
01/01/2006 12:05:38: Run: '\Windows\cgacutil.exe /silent /id \Windows
\Microsoft .NET CF 2.0.GAC', error code: 0 (00000000), exit code:
-2147483648 (80000000)
01/01/2006 12:05:38: GACing: failed.
01/01/2006 12:05:38: Unable to add files to GAC. Installation aborted.
01/01/2006 12:05:38: Memory status, K --------------------------
01/01/2006 12:05:38:   Load           : 27
01/01/2006 12:05:38:   Physical       : 55864
01/01/2006 12:05:38:   Physical free  : 41136
01/01/2006 12:05:38:   Virtual        : 1048576
01/01/2006 12:05:38:   Virtual free   : 1047936
01/01/2006 12:05:38: Storage status, K -------------------------
01/01/2006 12:05:38:   Available to us: 49792
01/01/2006 12:05:38:   Total storage  : 55768
01/01/2006 12:05:38:   Available total: 49792
01/01/2006 12:05:38: -------------------------------------------
01/01/2006 12:05:38: Entered Uninstall_Init().
        Installation folder is: '\Windows'.
......................
......................
.......................


Can anyone assist?


Thanks

6. Running executables from a c# programme

7. embedding executable as resource?

Hi,

Let's say I have a project, and I add notepad.exe into it and set its
property as an embedded resource.

Now, when I build the project and run it, I want my code to launch
notepad.exe.  How can I do this?

Thanks in advance,
Davsi

8. Process invoking an executable - CSharp/C#