|
int SynchronizedThread::RunCommand(CString Command, bool WaitForIt)
{
PROCESS_INFORMATION ProcInfo;
STARTUPINFO StartInfo;
DWORD exit_status;
memset(&StartInfo, 0, sizeof(StartInfo));
StartInfo.cb = sizeof(StartInfo);
if (CreateProcess(NULL, (LPSTR)(LPCTSTR)Command, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &StartInfo, &ProcInfo))
{
if (WaitForIt)
{
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcInfo.hProcess, &exit_status);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
}
else
exit_status = EXIT_SUCCESS;
return exit_status;
}
return EXIT_FAILURE;
}
|
|
|
|
|
I dont need monitor the thread, I need to know how get the return of line command of executable.
Example... my program of MFC needs to get this '1.00'
prompt (line command)
c:\download.exe /v
1.00
c:\
Do you know to get it?
|
|
|
|
|
Of course you need to monitor the thread, the exit code isn't available until the program exits and how do you know when that happens unless you monitor the thread?
You don't have to sit and wait until it's done, you can periodically check the state of the thread (wait with a short timeout or other "test" conditions for the state of the handle) and then you'll know the exit code is valid.
Also, it's better to have the command line be "Download.exe /v" (whatever /v means to your program) than to have a .BAT file run the command. This way you'll be sure to get the exit code of the application.
|
|
|
|
|
Sorry, I forgot the console application, the main return an int;
Now, I understood the GetExitCodeProcess() getting the int main.
Thanks
André.
|
|
|
|
|
Minifilters get passed a PFLT_CALLBACK_DATA and a PCFLT_RELATED_OBJECTS when called by the system.
Does anyone know of a way to change, or add, parameters to the application being run?
==============================
Nothing to say.
|
|
|
|
|
_itoa can convert int value such as 15 to F, but the atoi function cannot convert it back. it simply treat any letter that is not numerical( '0' - '9' ) as wrong input value.
I have an edit control to display something hexadecimal, say a pointer, a handle,so I do the follow,
_itoa( i, szBuffer, 16 ) ;
SetDlgItemText( hDlg,szBuffer ) ;
when I want the value back, I need to convert it back to int representation. But I am stuck here.
Does someone know any function that fix my problem?
|
|
|
|
|
|
|
I keep getting this error from my program when I try to debug it.
Program: C:\Users\Jeffrey\Desktop\WinSTM\.\Debug\WinSTM.exe
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\filelist.cpp Line:225
It is referring to this piece of code:
ENSURE(SUCCEEDED(hr));
Add(psi, strAppID);
#endif
Can anyone help tell me what this is referring to so that I can fix it?
solved here:Debug Assertion Error Visual Studio 2010[^]
modified on Thursday, August 25, 2011 3:47 PM
|
|
|
|
|
AndrewG1231 wrote: Can anyone help tell me what this is referring to so that I can fix it?
The ENSURE() macro expands to a macro named ENSURE_THROW() . That macro is the one that actually contains the assertion. You might look in afx.h around line 369 (I don't have VS2010) to see what condition is actually asserting.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I think Code-o-Mat is on to something in his response to your previous thread below.
Change this:
if (m_Bitmap != 0)
DeleteObject(m_Bitmap);
To this:
if (m_Bitmap != 0)
{
DeleteObject(m_Bitmap);
m_Bitmap = NULL;
}
Compile it, and see if the error occurs again.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, I have made this change and the error persists.
|
|
|
|
|
Thanks. Too bad it didn't solve the main problem, but nevertheless it was probably not working correctly.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
The ENSURE and SUCCEEDED macros are quite commonly used to throw a debug assertion failure when some API call returns "false" or "failed" or whatever.
"hr" is the interesting variable being checked and is a common name for "handle for a resource".
If you found the "ENSURE" statement, the really interesting part is above it, where the value of "hr" was set to something the "ENSURE" statement is unhappy with. Look at that.
When you hit the assertion failure and enter the debugger, follow the call stack backwards (down in the listing) until you find something that's in your own code and double click on that, it will take you to your call that called the API that had the argument it was unhappy with. Follow that procedure over and over until you find the call that really messed up the argument.
Remember this process as it will help you over and over again as you run into problems in the future. There is no substitute for learning a good debugging procedure and how to use the debugging tools in your compiler.
|
|
|
|
|
Yes, the hr value is E_INVALIDARG....will this indicate a bad pointer value?
|
|
|
|
|
You need to first find the call that fails. Then lookup that function to see why it would return "E_INVALIDARG". For example, if the function want's a handle, E_INVALIDARG might indicate an invalid handle. If it wants a pointer, maybe NULL would cause E_INVALIDARG.
There's no way, without knowing what API function is returning the error, to guess what would cause E_INVALIDARG. Now that you know what the error is, you should do a little research to figure it out.
Here's a suggestion. Now that you know where the error occurs, not the "ENSURE" call but the API call that return "hr" as "E_INVALIDARG", set a breakpoing *before* executing the API and look at the arguments you are passing. Compare them to what the documentation for the function says.
Debugging something you didn't write can be a challange but a little common sense can help unwind the reasons and might help you understand what the code is trying to do.
|
|
|
|
|
Thanks for the suggestion!
|
|
|
|
|
Frames in many animated gif files don't have transparent color, that is, transparent color index of the frames is not valid (Transparent Color Flag is zero).
In the case, I guess, the frames use default transparent color : white - rgb=(255,255,255).
But I can not find docs on google to confirm it.
If you have knowledge about animated gif format, please let me know if my guess is true.
BTW:
all gifs of this kind found by me have white background, that is why I think there is default transparent color for this kind gifs.
|
|
|
|
|
here is the GIF Spec[^].
there is no default transparent color, AFAIK. typically the rendering code just picks a color like white or black, or the app lets the user choose a color when rendering transparent images, of any format, when there is no background.
|
|
|
|
|
I am new to DirectDraw,I found it hard to find DirectDraw document on MSDN, it's all about D3D stuff which I don't really want to learn by now. So How should I start with DirectDraw? Any book/way recommended? thanks in advance.
|
|
|
|
|
From MSDN http://msdn.microsoft.com/en-us/library/gg426115(v=VS.85).aspx[^]
DirectDraw is no longer recommended for use. With the release of Direct3D 9.0, all two-dimensional functionality is contained within Direct3D, its associated helper functions in D3DX, and the DirectX 11 technology Direct2D. However, the DirectDraw reference documentation is still available in this section.
While I'm sure there are books that cover the older DirectDraw, you might as well start learning 2D drawing within the context of Direct3D.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
meh. don't bother. MS will come out with yet another API which will obsolete all the others, in the next two or three months. like they always do.
|
|
|
|
|
Considering that DirectDraw was part of DirectX in 1995, and was superceeded in 2001 with Direct3D. So the API the original poster wanted to use is 16 years old, and was replaced 10 years ago.
Considering the advances in video rendering, having a the same basic API for the past decade isn't bad.
/* Charles Oppermann */
http://weblogs.asp.net/chuckop
|
|
|
|
|
Thanks, I think I am stick with DirectDraw7.0.
|
|
|
|
|
I tryid to read every file from MRU ( registry ) with follow code :
void CFileSourcePage::GetKey(HKEY hKey, LPCTSTR lpSubKey, CStringArray& saResult)
{
if(RegOpenKeyEx(hKey,lpSubKey,0,KEY_READ,&hKey) != ERROR_SUCCESS)return;
DWORD dwType;
BYTE bData[4096];
DWORD cbData = 4096;
TCHAR achKey[MAX_KEY_LENGTH]; DWORD cbName; TCHAR achClass[MAX_PATH] = TEXT(""); DWORD cchClassName = MAX_PATH; DWORD cSubKeys = 0; DWORD cbMaxSubKey; DWORD cchMaxClass; DWORD cValues; DWORD cchMaxValue; DWORD cbMaxValueData; DWORD cbSecurityDescriptor; FILETIME ftLastWriteTime;
DWORD i, retCode;
TCHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
retCode = RegQueryInfoKey(
hKey, achClass, &cchClassName, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, &cValues, &cchMaxValue, &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
if(cSubKeys)
{
TRACE1("\nNumber of subkeys: %d\n", cSubKeys);
for(i = 0;i < cSubKeys;++i)
{
cbName = MAX_KEY_LENGTH;
retCode = RegEnumKeyEx(hKey, i,
achKey,
&cbName,
NULL,
NULL,
NULL,
&ftLastWriteTime);
if(retCode == ERROR_SUCCESS)
{
TRACE2("(%d) %s\n",i + 1, achKey);
}
}
}
if(cValues)
{
TRACE1("\nNumber of values: %d\n", cValues);
for(i = 0,retCode = ERROR_SUCCESS;i < cValues;++i)
{
cchValue = MAX_VALUE_NAME;
retCode = RegEnumValue(hKey, i,
achValue,
&cchValue,
NULL,
&dwType,
bData,
&cbData);
if(retCode == ERROR_SUCCESS)
{
LPSTR pszValue = reinterpret_cast<LPSTR>(bData);
saResult.Add(pszValue);
}
}
}
RegCloseKey(hKey);
}
and in OnInitDialog() I try :
CStringArray saMRU;
CString sFile = theApp.GetProfileString(_T("Settings"),_T("File"));
GetKey(HKEY_CURRENT_USER,_T("Software\\MyPlace\\Application\\Recent File List"),saMRU);
but altought I have 3 files there :
C:\eeeeeeeeeeeeeee.xyz
E:\Flaviu\VC++\MDI\Application\aaaaaaaaaaaaaa
E:\Flaviu\VC++\MDI\Application\gbdhfdfgf
is reading only first and last file in CComboBox .... why ? What I'm doing wrong ? Thank you.
|
|
|
|
|