|
-
Mar 15th, 2002, 12:21 AM
#1
Thread Starter
Fanatic Member
What are the Standard Header Files?
I want to write a small proggie in C++ 5 (or 6). It should not have an interface, and it should not have MFC support or database support. All it has is the main function:
void main () {
// trivial code here
}
My program NEEDS to include a minimum of headers and stuff -- smaller is better!!!!!!!!! BUT, I need to perform a ShellExecute call in main, so what is the minimum number of header files I need for this?
I tried including <windows.h>, but I get an unresolved external ref or whatever. The problem is something to do with "Win16main" or something like that.
I am sure the answer is simple, but what am I doing wrong????
-
Mar 15th, 2002, 08:57 AM
#2
You either can create a console application and write a main function, or create a GUI function and write a WinMain function. If you don't want anything to appear you write a GUI app, a WinMain, include <windows.h> but don't create a window, just use the ShellExecute.
Actually, you don't need any include at all:
Code:
extern "C" void* ShellExecuteA(void*, const char* szOp, const char*szFile, const char* szParams, const char* szDirectory, int iShowCmd);
int WinMain(void* hInst, void*, char* szParams, int iShowCmd)
{
int iErr = (int)ShellExecuteA( // the HINSTANCE return is for compatibility only
0, 0, // no parent and no op (= open)
"drive:\\path1\\path2\\filename.ext", // the file to open
szParams, // just pass our own params
"drive:\\path1\\path2", // default path is execution directory
iShowCmd); // show the same way this was intended to be shown
}
And you only need one import libraray, I think it's SHLWAPI.LIB.
Then you have a valid app.
Of course this is not recommended.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 15th, 2002, 02:30 PM
#3
Thread Starter
Fanatic Member
Ah, OK. That makes sense.... I am sure I can figure out the rest.
Thanks a lot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|