|
It appears the DLL is not sending character messagges to your executable.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes it does!
Because I tested it in this way:
if(msg.wParam == WM_KEYDOWN)MessageBox("Something");
After that I received the above message (within MessageBox()) whenever I pressed a key any where!
|
|
|
|
|
Get the extended error information using GetLastError function.
Regards,
Rane
|
|
|
|
|
Usef Marzbani wrote: if(msg.wParam == WM_KEYDOWN)
Huh? Why would WM_KEYDOWN be in msg.wParam?
Is that how you post the message?
That's fine if you do, but TranslateMessage isn't going to understand
that message.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is there a way to send signals/messages to a console window? I need control the behavior of a console application from another application.
I'm not sure if signals or messages is what i'm looking for but i wouldn't like to use pipes or shared memory for this simple task
Thanks
|
|
|
|
|
You can redirect it's I/O so that your parent app can read what the child app writes with printf and your parent app can write what the child app receives from scanf. There's a class CRedirector[^] that implements this.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I know but that's exactly what I'm looking for. I'd like the child app to handle messages during its sleep time as it happens with CTRL_C_EVENT if I call SetConsoleCtrlHandler
|
|
|
|
|
Hi all,
I am using VISTA and vc++ (using VS-2008).
In my application I am creating one .bat file using CreateFile function, after creating it I am writing three commands in to this file using WriteFile. Now I am running it by using Shellexecute() function.
The code piece is-
CString csRunCommands = _T("bcdedit /set {bootmgr} device boot > d:\\zzz1.txt");
HANDLE hBatFile = CreateFile(_T("D:\\myBat.bat"),GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,OPEN_ALWAYS,0,NULL);
WriteFile(hBatFile,csRunCommands,csRunCommands.GetLength()*2,&dwReturnVal,NULL);
CloseHandle(hBatFile);
iReturn = (int)ShellExecute(NULL,_T("Open"),csFilePath,NULL,NULL,SW_SHOWNORMAL);
csRunCommands is a CString variable that contains the commands to be written.
All the code is running without problem. Return value of ShellExecute is 42 ie gretaer than 32 it means file is getting executed.
In the command that I am writing into file I have mention pipe that save the output in to one text file (D:\zzz1.txt). But after executing the code I am not seeing any zzz1.txt file in D:\ drive.
If I make a .bat file manually(say man.bat) and edit that by writing same command and run it as administrator then it is saving the output of command in to this text file as "The Operation completed successfully".
Please suggest me so that I can execute this .bat file by my code.
Thanks
|
|
|
|
|
Is there a reason why you cannot run the command directly, like
system(csRunCommands);
bypassing the batch file?
|
|
|
|
|
Hi thanks for replying,
If I use system() then the command screen will reflect. I want to execute this without any black screen (by hiding the command execution).
When I try to run this .bat file by command prompt(opening cmd as administrator) like- D:\myFolder\mybat.bat then it is saying that 'b' is not recognized as an internal or external command. 'b' is the first character in my command that is written in that file.
If I am not wrong, the problem is arising due to unicode because I am writing the command in to file through my code using WriteFile function and second parameter of this function is as-
csRunCommands = _T("bcdedit /set {bootmgr} device boot > d:\\zzz1.txt");
If I make a bat file in any drive manually and write the same command there then it is getting execute well.
Please give me some solution.
thanks
|
|
|
|
|
Madan Chauhan wrote: the problem is arising due to unicode
correct. The batch file has to be in single byte ACSII encoding.
|
|
|
|
|
Could you please give me the idea that how can I write in ASCII code in to a bat file. or After writing in unicode to a bat file can I convert the matter that the bat file contain in to ASCII.
waiting.
|
|
|
|
|
You could use CStdioFile::WriteString and open the target (batch) file with the flag CFile::typeText .
|
|
|
|
|
Thanks for the suggestion.
I used it by ::
FILE *f=fopen("D:\\myBat.bat","w");
fprintf(f,"%s\n","bcdedit /set {bootmgr} device boot > d:\\zzz1.txt");
fclose(f);
And the problem resolved.
Thanks again for your support.
|
|
|
|
|
|
Can you try with WinExec instead of ShellExecute?
Regards,
Rane
|
|
|
|
|
Hi I just tried it by using WinExec but getting the same problem.
I think the problem is arising due to unicode. I am writing in to file in unicode.
Could you please tell me that how can I convert the matter of any .bat file from unicode to ASCII.
or how can I write the commands in ASCII in to bat file that I am writing in unicode this time.
thanks.
|
|
|
|
|
Madan Chauhan wrote: WriteFile(hBatFile,csRunCommands,csRunCommands.GetLength()*2,&dwReturnVal,NULL);
Why are you using a hard-coded 2 rather than sizeof(TCHAR) ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi there,
i am currently working on a Shell Namespace extension. In order to provide it with different Icons for my different elements, i use some image-lists to store the images. Since for every folder i browse there might be several newly created images necessary, i want to delete the lists and fill them up new. But as soon as i add the call to CImageList::DeleteImageList(), the DLL cant be registered anymore.
I guess i am missing some fundamental knowledge about how to use MFC. If it helps discoverig my fault, i can also state that every time i want to open a contextmenu or pop up a dialog, i have to add the line:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
to the calling method because otherwise they dont show.
Due to the fact that i am pretty new to MFC-programming i bet there must be some configuration-stuff that i have to do initially to solve my problems.
can anyone help me out?
thanks in advance,
Gernot
|
|
|
|
|
Maybe its also interesting, that i dont even get an error-dialog, when i try to regsvr32 my DLL, but it just doesnt register. Visual studio says
"1>Project : error PRJ0019: A tool returned an error code from "Performing Post-Build Event...""
when i try to register in Post-Build-Routine.
|
|
|
|
|
Meanwhile i dependencywalked out what is it, that fails while trying to register:
"LoadLibraryExW("C:\projekte\Namespace Extension\MyProject\Debug\MyPlugin.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: Das System hat keinen Meldungstext fr die Meldungsnummer 0x%1 in der Meldungsdatei %2 gefunden (317)."
The text means something like "the system doesnt provide a text for this error".
Unfortunately, this doesnt help me alot. Has anyone had a similar problem or any idea that might help me out? im really stuck here!
|
|
|
|
|
CImageList::DeleteImageList() calls AfxImageList_Destroy() but in doing some quick searches, I don't see the source for AfxImageList_Destroy() in my VC8 install dir. That is weird.
|
|
|
|
|
Yes, youre right. I cant find it, too.
And it seems to be exactly that call, that doesnt work anyhow. I dont know what else to do. Is there any other possibility of cleaning that up? My extension works so far, but every time i open a folder, i get more and more GDI-Objects for the explorer.exe.
|
|
|
|
|
Dear All
which Event is fired when in a multi Property page Tab control,we change from one tab to another one.
Regards
Monhi
|
|
|
|
|
TCN_SELCHANGE
Regards,
Rane
|
|
|
|