Rather than system(), you want to use popen(). The only problem is that popen() doesn't supply a separate FILE for stderr, so you have to use output redirection to capture both e.g.
FILE *cmd = popen("hcitool dev 2>&1", "r");
char *buffer = NULL;
size_t len = 0;
while ( (readlen = getline(&buffer, len, cmd)) >0)
/* process input buffer */
You could perhaps also use output redirection to capture output separately e.g.
FILE *cmd = popen("hcitool dev 2>/tmp/hcierrs", "r");
/* process input as above */
FILE *cmd_errs = fopen("/tmp/hcierrs", "r");
/* loop through input from cmd_errs ... */
If you're going to do that, you might want to look at creating unique temporary file names, so that you don't clobber output if you happen to have more than one instance of the program running at the same time. mkstemp() can help you here.
For the really advanced, you might look into trying "roll your own" version of popen that uses fork() and one of the exec() functions to separate out stdout and stderr to two separate FILES.
I am using an outlook bar style property sheet with 3 property pages as the main window of my application.I am unable to change the tab icons displayed on the property sheet.Please suggest any strategy to change the icons.I have gone through all the documentation related to property sheets
and also googled but I couldn't get a solution. I have code which is not working and will post it if required.
In such a case I'd recommend to subclass the CMFCPropertySheet (derive your own class from it) and overload the SetIconsList method. Or better implement the new method (say, ReplaceIcon) that would directly manipulate (remove/add/replace an image) with the m_Icons imagelist.
Then investigate the afxpropertysheet.cpp (and probably some more (friend and other classes) source code to see where and how the m_Icons imagelist is involved and try to change it according to your needs!
Got the answer mostly due to Microsoft Q&A This code placed in the derived property sheet works if the bitmap images are all of exactly the same size Thanks also to Victor Nijegorodov for his suggestions:
retval=m_wndPane1.AddButton(m_bmpimgs, "Create a Job", 10050, 0);
retval=m_wndPane1.AddButton(m_bmpimgs, "Manage a Job", 10051, 1);
retval=m_wndPane1.AddButton(m_bmpimgs, "Restore a Job", 10052, 2);
I am not really sure what you mean by 'try to load the .exe as a resource' does the bitmap have to be linked into the .exe
Just open your VS, then Menu -> File -> Open -> find in the open file dialog (File Explorer) your .exe file -> open it!
Then you will see the tree with all the embedded resources. Just navigate to the Bitmap hive and ensure that the bitmap with your bitmap ID does exist!
You should not need to as the location is only required by the compiler when it builds the executable. Part of the build process is to embed all resources into the final executable. You can check it by getting hold of one of the many free resource editors available online.
Did a Cimage load the HRESULT was 0 did CBitmap::Attach (there is not documentation on this) but return code was 1 when I looked at the n_hObject in VS debugger it had high order X'FF' the handle was FFFFFFFF88052070 never saw a resource handle with high order X'FF' ITS usually zeros