|
Yep. You need "Teach Yourself VC in 90 days", at least!
Sounds like you don't have the MSDN - you can look things up online here: msdn.microsoft.co[^]m (use the search box in the top-left corner)
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Used to have the full MSDN, but lost the disks, and had to reinstall my system at some point in the past. Really do miss em though.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
After doing some rather deep digging here in the forums, I've found the following snippet:
STARTUPINFO siInfo;
PROCESS_INFORMATION piInfo;
siInfo.cb = sizeof(STARTUPINFO);
siInfo.lpReserved = 0;
siInfo.lpDesktop = NULL;
siInfo.lpTitle = NULL;
siInfo.dwFlags = STARTF_USESHOWWINDOW;
siInfo.cbReserved2 = 0;
siInfo.lpReserved2 = NULL;
CreateProcess("F:\\path\\program.exe", "", NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, "F:\\path\\", &siInfo, &piInfo);
Now, you were saying to pass the handle to WaitForSingleObject(), but which of the above is the handle?
(plus, i'm still slightly confused on what all that is, but if it works, great)
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Consulting my MSDN ( ), CreateProcess() returns the following in piInfo:
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwThreadId;
where hProcess is the handle (i.e. an internal system cookie, if you like) for the process and hThread, a handle for the process's primary thread. The ID's are unique numbers for the process and thread but are not terribly useful.
So, you pass the hProcess in to WaitForSingleObject(). If you specify a timeout of INFINITE, this call will block until the process ends. Or if you use 0, it will do a quick check to see if the process is alive at that moment. Or you can pass in a number of milliseconds - the call will wait for that amount of time for the process to finish and return a value indicating whether it did or not.
Don't forget to call CloseHandle() for both these handles when you're done otherwise you'll get a leak.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Your answer, although informational, was still a bit cryptic. However, you did give me enough information to work with, that I could use msdn.microsoft.com to find the rest. This little bit of sample code, along with your advice, lead me to just what I was looking for.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
"MyChildProcess", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
ErrorExit( "CreateProcess failed." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Magius96 wrote:
Your answer, although informational, was still a bit cryptic.
Well, we don't want to make it *too* easy for ya!
What you've got looks pretty spot on.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Ok, now that I've got that much working, perhaps you'd entertain me to give me a suggestion(tease me more like it), on how to convert a CString to char. I'm passing command line arguments from a user interface, but the darn compiler is complaining that they must be char's and not CString class. My luck eh? Almost complete, and I throw a wrench into the darn thing.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Cast it it a (LPCTSTR). Or look at GetBuffer().
Hmmm... Not cryptic enough, by far.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(si);
int rv = CreateProcess(0, pCmdLine, 0, 0, 0, 0, 0, 0, &si, &pi);
if (rv)
{
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
You made it this far. Why not just search google.com, msdn.microsoft.com, or THIS site for CreateProcess?
Todd Smith
|
|
|
|
|
I'm sorry, I had forgotten to post that I figured it out after the previously not so cryptic message. Thanks for your help anyways.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Is there an API function to retrieve the icon of a particular document, or do I have to acquire it myself by scanning the registry?
--
This space for rent.
|
|
|
|
|
I've looked for this in several projects I've done, and have always resorted to the registry.
A simple class for this would be useful to have on hand.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
Colin Davies wrote:
A simple class for this would be useful to have on hand.
I'll submit an article about such a class, if I figure out a nice way to do it. Wish me luck!
--
This space for rent.
|
|
|
|
|
The class will be finished by dawn, sir.
--
This space for rent.
|
|
|
|
|
It's already dawn where I'm at, Sir.
"Don't tell me I'm smart, I might actually believe you!"
|
|
|
|
|
Try using ShGetFileInfo . It works for all Win32 versions of Windows.
Software Zen: delete this;
|
|
|
|
|
Argh... I just wrote an article on how to grab the data from the registry.
Thanks for the info though!
--
This space for rent.
|
|
|
|
|
Hey - Submit the article anyway. I'd like to read it. Any information on how Windows uses the registry is useful!
Software Zen: delete this;
|
|
|
|
|
Doh! I deleted it. I didn't want to use CP as a storage when there's already an API function for it!
Here's however a simple rundown of the implementation if you're interested:
- For a file extension "doc", open HKEY_CLASSES_ROOT\.doc Look at the default value. It's a part key name, for instance Word.Document.8. Also, HKEY_CLASSES_ROOT\.doc may contain information such as content type (mime) worth collecting
- Assuming the key name was Word.Document.8, open HKEY_CLASSES_ROOT\Word.Document.8
- Collect the data you want from here (default icon, file type descriptions, etc.)
I have the code lying around still if you want it.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I do it with SHGetFileInfo() , however AFAIK it doesn't restrieve the 48x48 icon, only 16x16 and 32x32. Here's how to get the icon for DLL files:
SHFILEINFO sfi = {0};
SHGetFileInfo ( _T("foo.dll"), FILE_ATTRIBUTE_NORMAL,
&sfi, sizeof(SHFILEINFO),
SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |
SHGFI_LARGEICON );
Replace SHGFI_LARGEICON with SHFGI_SMALLICON to get the 16x16 one.
Note that foo.dll doesn't need to exist, the SHGFI_USEFILEATTRIBUTES flag tells the API to just look at the extension of the name you pass.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Argh... I just wrote an article on how to grab the data from the registry.
Thanks for the info though!
--
This space for rent.
|
|
|
|
|
Here is a simple question I have had a hard time finding an answer for. I have a program which reads and writes MS Jet DB (.mdb) files. I want to make sure that the files are not in use by another process, and the the program has exclusive access to the file. Is there a function that I can use to determine if the file is open or not? Or should I use the CDaoDatabase functions to see if it is use? I assume I should test the file to see if it is open. I know CFile will return an error, but is there a way to test if the file is open before it is opened? Thanks for any help!
|
|
|
|
|
John Clump wrote:
Is there a function that I can use to determine if the file is open or not?
I'm sure there is a better way to do this, however you could check for a file with the same name as the database, but with a file extension of ".ldb ". This is file that contains record locking information. It appears when your Access application is open and is deleted when Access is closed. Again I think there is probably a better way to do this, but it is another option.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Hi..
I have notices in my application that dialogs are not rendering (being painted immediatly) after creation..
I am creating my dialog, then i manually show the window (via showwindow) but all I get is a taskbar window icon but nothing on the desktop..
can anybody tell me how to forcibly show the dialog or is there something I can wait for (a signal of sometype). ??
Cheers
Chris
|
|
|
|
|
You can force a repaint by doing:
myDialog.Invalidate();
myDialog.UpdateWindow();
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|