|
First I'd suggest you get the MSDN CD's, so you can look up these commands for yourself ( not that I mind helping, but you'll go crazy if you need to kick back and wait a day to find out things like the syntax for ShellExecute ).
(From MSDN)
ShellExecute
Performs an operation on a specified file.
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
Parameters
hwnd
Handle to a parent window. This window receives any message boxes that an application produces, such as error reporting.
lpVerb
A string, referred to as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. For more information about verbs and their availability, see Object Verbs. See Extending Shortcut Menus for further discussion of shortcut menus. The following verbs are commonly used: Verb Description
edit Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
explore Explores the folder specified by lpFile.
find Initiates a search starting from the specified directory.
open Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.
print Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.
If you set this parameter to NULL:
For systems prior to Microsoft® Windows® 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.
For Windows 2000 and later systems, the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.
lpFile
Address of a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully-qualified parse name. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb.
lpParameters
If the lpFile parameter specifies an executable file, lpParameters is an address to a null-terminated string that specifies the parameters to be passed to the application.The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.
lpDirectory
Address of a null-terminated string that specifies the default directory.
nShowCmd
Flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it. SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the z-order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active.
SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
Return Values
Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Microsoft® Windows® applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an integer and compare it with the value 32 or one of the error codes below.
0 The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_BAD_FORMAT The .exe file is invalid (non-Win32® .exe or error in .exe image).
SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
SE_ERR_DDEBUSY The DDE transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL The DDE transaction failed.
SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND The specified dynamic-link library was not found.
SE_ERR_FNF The specified file was not found.
SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
SE_ERR_OOM There was not enough memory to complete the operation.
SE_ERR_PNF The specified path was not found.
SE_ERR_SHARE A sharing violation occurred.
Remarks
This method allows you to execute any commands in a folder's shortcut menu or stored in the registry.
To open a folder, use either of the following calls:
ShellExecute(handle, NULL, path_to_folder, NULL, NULL, SW_SHOWNORMAL);
or
ShellExecute(handle, "open", path_to_folder, NULL, NULL, SW_SHOWNORMAL);
To explore a folder, use:
ShellExecute(handle, "explore", path_to_folder, NULL, NULL, SW_SHOWNORMAL);
To launch the Shell's Find utility for a directory, use:
ShellExecute(handle, "find", path_to_folder, NULL, NULL, 0);
If lpOperation is NULL, the function opens the file specified by lpFile. If lpOperation is "open" or "explore", the function will attempt to open or explore the folder.
To obtain information about the application that is launched as a result of calling ShellExecute, use ShellExecuteEx.
See Also
IShellExecuteHook
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Shellapi.h.
Import Library: Shell32.lib.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
CString strFileName("c:\hello.exe");
ShellExecute(NULL, _T("open"), strFileName, NULL, NULL, SW_SHOW);
|
|
|
|
|
|
It depends on how much control you want over the running process. You could use
WinExec
ShellExecute
CreateProcess
Next, you can use one of the 16 available _spawn() variations, or one of the 16 available _exec() variations.
My advice is to buy a book about the Windows API and one about the C runtime library, and research your requirements.
|
|
|
|
|
Hi I began a course in visual c++ a little while ago and just started actual coding about 2 weeks ago. I have to make a simple dialog based program that calculates a paycheck total. Sounds easy but I havn't been given any calculation examplesfor dialog based therefore I'm stumped as to how to accomplish this task.
what i need is to get the entered text from 2 edit box's, multiply them together and display the total in a third edit box.
I'm embarrased to ask for help on something that seems so simple but i'm stumped. Thnx if anyone can help me out on this one.
|
|
|
|
|
GREETINGS Kron.
So you have 3 textboxes and 3 members- m_1, m_2, m_3(use MFC ClassWizard to create them). All members are int.
void CT1Dlg::OnOK()
{
UpdateData(true);
m_3=m_1*m_2;
UpdateData(false);
}
That's all.
Good Luck!
LOVE & PEACE to everyone
LOVE & PEACE to everyone
|
|
|
|
|
In a programe ,I want to display Windows Metafile ,but I'm failed to do it. So I want to get some help from here!
How can I display WINDOWS METAFILE
|
|
|
|
|
I'm trying to learn ATL and my project is a series of GDI+ graphics filters ( invert, colour, gamma, brightness, emboss, you get the idea ), so I want to create methods like this:
[id(1), helpstring("method DoInvert")] HRESULT DoInvert([in, out] Bitmap * i)
How can I do this ? How can I use COM to pass a Bitmap* into my method ? Is there a way of doing this so that I can still make it an ActiveX control to be used in VB ? Should I care ( i.e. can they access GDI+ anyhow ) ?
Thanks to all who respond....
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
VB can't deal with a Bitmap* object. You mgiht try
[id(1), helpstring("method DoInvert")] HRESULT DoInvert([in, out] HANDLE hBitmap)
VB has certain data type restrictions. If you want your ActiveX to be compatible with VB then you have to use the proper data types in your interface. Look in the docs for a list.
VB can not access GDI+.
|
|
|
|
|
If you need your component to be accessible from VB, you are restricted to using types from the VARTYPE enum - long, IDispatch*, etc. See wtypes.h or MSDN for the full list.
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
That's pretty much what I thought. So if I discard the idea of VB support, what do I need to do to pass a Bitmap * ? Did I just forgert a #include, or is the problem deeper ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I'll have to defer to someone else on that question - I've done little IDL hacking myself; I've always been able to get by with VARIANTs.
--Mike--
http://home.inreach.com/mdunn/
Sometimes, arming yourself with a big pointy stake just won't do you any good.
|
|
|
|
|
Thanks - I managed to do it with VT_PTR, although passing a void * doesn't thrill me. If anyone knows of an alternative, I'd be pleased to hear it, but my project is away, two filters implimented and working nicely. I have a whole swag written as classes, I just need to turn them in to ATL interfaces. I'm so glad I finally am writing ATL code, I've intended to for 18 months.
Lots of ATL questions coming up....
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
As was suggested before pass a HANDLE, but twist it. Since HANDLE is typedef'd as LONG use that.
[id(1), helpstring("method DoInvert")] HRESULT DoInvert([in, out] LONG* hBitmap)
Notice it is also a pointer since it both in and out. I believe you can get the HBITMAP from VB to pass into the method.
What about using IPicture?
|
|
|
|
|
I think that passing in an IPicture is the 'proper' COM approach.
|
|
|
|
|
The thing is, I don't want to pass a CBitmap * or a HBITMAP, but a Bitmap object from GDI+, because that is what I am working with, and I want to use BitmapData* to traverse the bitmap. I suppose I could create a DIBSection, but it would take time and generally be an ugly approach when I have a perfectly good formated object to start with ?
It looks like the VARIANT is going to win... Thanks to everyone for their suggestions.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
OK....
So, can you pass pointers to classes through ATL? For now let's assume C++ to C++ only. For instance, could you pass CArchive?
I live in hope...
> Andrew.
|
|
|
|
|
You can pass the pointer as a long, as pointed out earlier. Whether that pointer has any meaning on the other side...
|
|
|
|
|
i need to know how i can delete a cookie or all temporary internet files at once.
Thanks
Kun
|
|
|
|
|
How to retain the child windows' title when moving around different child windows.
I used SetWindowsText but it disappears when other child window is activated.
Gracias
|
|
|
|
|
i need to store the path (only the path) where my .exe file is run from in a string.
groovy, hehe
oops yea, i also need to know how i can delete a cookie in the temporary internet files folder because they dont seem to act as files
Thanx!
Kun
|
|
|
|
|
I pulled this from my library of routines
Good luck with the cookies
Brad
CString GetLaunchedDir()
{
TCHAR szFullPath[MAX_PATH];
TCHAR szDir[_MAX_DIR];
TCHAR szDrive[_MAX_DRIVE];
CString strLaunched;
::GetModuleFileName(NULL, szFullPath, MAX_PATH);
_splitpath(szFullPath, szDrive, szDir, NULL, NULL);
strLaunched.Format(_T("%s%s"), szDrive, szDir);
return strLaunched;
}
|
|
|
|
|
Hai,
I made a program to input .txt into MS Access.The text file is an output of a math program.Fine.
Now another program retrieves the data and displays it in the list control.Not fine.
The problem is the numbers displayed in the list contains an additional point other than the one already present.
When I checked in the database,it was correct ie same as that in the text file but the point gets added in the list control.Why?Whats the point?
The database fields are strings.
This problem occurs only to certain numbers in random.
I am confused.I need to use this in further calculations but it will harm my other calculations.
Help me.
And this,both the programs DONOT work simultaneously.The first was just a tool to help inputting thousands of numbers from text.
Thanx.
|
|
|
|
|
Hi all,
What is Project->Setting->C/C++->Optimazation ?
I can see Maximize Speed ...
Is that for speed in executing my EXE file ?
I mean, if i choose that, my EXE file will running faster ?
So, this option is for my EXE speed ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
yes, it's the speed of your exe...
A compiler man make different optimizations of your code. It can make your program run faster, make a smaller executable, and other stuff.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|