Click here to Skip to main content
15,887,676 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUI widget Pin
Member 1152499814-Mar-15 6:52
Member 1152499814-Mar-15 6:52 
QuestionFeatures and rich documentation of MFC vs Small Executable of WTL Pin
Member 1120327711-Mar-15 4:21
Member 1120327711-Mar-15 4:21 
AnswerRe: Features and rich documentation of MFC vs Small Executable of WTL Pin
jeron111-Mar-15 5:53
jeron111-Mar-15 5:53 
AnswerRe: Features and rich documentation of MFC vs Small Executable of WTL Pin
Eddy Vluggen11-Mar-15 6:28
professionalEddy Vluggen11-Mar-15 6:28 
AnswerRe: Features and rich documentation of MFC vs Small Executable of WTL Pin
Albert Holguin15-Mar-15 17:29
professionalAlbert Holguin15-Mar-15 17:29 
QuestionSftTree.dll, v4.0.0.0 performance issue With C# Winform Pin
vipin kumar sharma10-Mar-15 1:43
vipin kumar sharma10-Mar-15 1:43 
SuggestionWrong Forum Pin
Richard Deeming10-Mar-15 2:04
mveRichard Deeming10-Mar-15 2:04 
QuestionEjecting USB memory sticks problem Pin
Still learning how to code10-Mar-15 1:07
Still learning how to code10-Mar-15 1:07 
I am developing an application to copy USB memory sticks. As part of this app, I want to be able to eject the memory sticks when copying is complete. (I DO wonder whether this is necessary as I do a file flush before closing the file) I found a nice little utility (deveject) to implement this and am calling it using WinExec() - I do realise that this is very old and I should be moving on to CreateProcess(), but it has worked well for me in the past and I'm in a bit of a hurry !! Although WinExec() returns 33 (which indicates success), the drives are still accessable aftyerwards and so deveject presumably has not executed properly As a test for the command line used, I placed it in a batch file (deveject -EjectName:"USB Mass Storage Device") in the same directory as deveject.exe, and it executes perfectly, releasing all USB sticks. However, if I use WinExec() to call this batch file, then it doesn't work (but good return code from WinExec() )
So my question is - what am I doing wrong when using WinExec() ? Should I be doing something (permission-wise)to allow the WinExec command line to execute ? My code is as follows:-

C++
CString szCmdLine;
const CString quote = "\""; // This is actually the character '"'

szCmdLine = "D:\\StickCopier\\deveject -EjectName:" + quote + "USB Mass Storage Device" + quote;
UINT uiRC;
uiRC = WinExec(szCmdLine,SW_HIDE);


(The command line formed is exactly what I used in the batch file)

Would greatly appreciate any help on this daft (but perplexing) problem !!

modified 10-Mar-15 7:44am.

AnswerRe: Ejecting USB memory sticks problem Pin
David Crow10-Mar-15 2:42
David Crow10-Mar-15 2:42 
GeneralRe: Ejecting USB memory sticks problem Pin
Still learning how to code10-Mar-15 3:04
Still learning how to code10-Mar-15 3:04 
QuestionDestructors Pin
lor759-Mar-15 8:11
lor759-Mar-15 8:11 
AnswerRe: Destructors Pin
David Crow9-Mar-15 9:22
David Crow9-Mar-15 9:22 
GeneralRe: Destructors Pin
lor759-Mar-15 9:39
lor759-Mar-15 9:39 
GeneralRe: Destructors Pin
Maximilien10-Mar-15 3:47
Maximilien10-Mar-15 3:47 
AnswerRe: Destructors Pin
Albert Holguin11-Mar-15 16:46
professionalAlbert Holguin11-Mar-15 16:46 
Questionc graphics Pin
Member 115074488-Mar-15 2:35
Member 115074488-Mar-15 2:35 
AnswerRe: c graphics Pin
Frankie-C8-Mar-15 4:18
Frankie-C8-Mar-15 4:18 
AnswerRe: c graphics Pin
Afzaal Ahmad Zeeshan11-Mar-15 7:43
professionalAfzaal Ahmad Zeeshan11-Mar-15 7:43 
Questioncryptosystem Pin
Member 115062768-Mar-15 1:54
Member 115062768-Mar-15 1:54 
AnswerRe: cryptosystem Pin
Richard MacCutchan8-Mar-15 2:09
mveRichard MacCutchan8-Mar-15 2:09 
AnswerRe: cryptosystem Pin
Chris Losinger9-Mar-15 6:31
professionalChris Losinger9-Mar-15 6:31 
Questionusb modem problem Pin
ali_heidari_7-Mar-15 7:32
ali_heidari_7-Mar-15 7:32 
AnswerRe: usb modem problem Pin
Frankie-C7-Mar-15 10:14
Frankie-C7-Mar-15 10:14 
GeneralRe: usb modem problem Pin
ali_heidari_7-Mar-15 17:54
ali_heidari_7-Mar-15 17:54 
QuestionCreating an .Obj File Pin
Bram van Kampen6-Mar-15 12:46
Bram van Kampen6-Mar-15 12:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.