|
Hey everyone!
I'm currently working on a project that is going to require access to various command line applications. Mostly in order to grab status updates from various processes that are running on the system.
A sample of the command line program would be as follows:
C:\Program\Folder>System.exe -Enable "10:22:00" -Disable "10:23:00"
SYSTEM ONLINE - 11/25/2009 10:22:35 GMT
SYSTEM ONLINE - 11/25/2009 10:22:40 GMT
SYSTEM ONLINE - 11/25/2009 10:22:45 GMT
SYSTEM ONLINE - 11/25/2009 10:22:50 GMT
SYSTEM ONLINE - 11/25/2009 10:22:55 GMT
SYSTEM OFFLINE - 11/25/2009 10:23:00 GMT
SYSTEM OFFLINE - 11/25/2009 10:23:05 GMT
SYSTEM OFFLINE - 11/25/2009 10:23:10 GMT
Etc. Etc. Etc.
I need to be able to grab that system status from this and other programs and return them to a GUI application in Visual C++.
How can I grab the resultant output of the console as a string? I realize that many people simply dump the data to a file and then read from the file, but I'm looking for something a bit more direct. Is this even the correct way to approach the problem of grabbing status from an external process? My restrictions are that it does have to be for Windows and in Visual C++.
Thanks for the help!
-N. Rackley
|
|
|
|
|
You will probably need to use the system() or _popen() call to get what you need. Take a look at the MSDN references[^] for more information.
|
|
|
|
|
|
Hi all..
I am facing a problem with the font selection in menu..
here the color of font is not changing once selected.. but the type and size everything is changing as per selection..
Iam using CreateFontIndirect
and below is my code for OnFont()
CWnd *pwnd = CWnd::GetFocus();;
int wID = pwnd->GetDlgCtrlID();
LOGFONT If;
CFont *font = new CFont();
if(wID==IDC_SAFE)
{
CFontDialog FontDlg(&If);
if(FontDlg.DoModal() == IDOK)
{
font->CreateFontIndirect(&If);
m_edittext.SetFont(font);
}
}
plz help me to solve it
|
|
|
|
|
I think you need to set the text colour independently of the font, with the value from the CFontDialog.GetColor() method.
|
|
|
|
|
thanku Richard...
n sorry for the late reply..
i tried implementing ur sggestion but dat too is not working....
|
|
|
|
|
sonualex wrote: i tried implementing ur sggestion but dat too is not working....
Sorry, but I cannot guess what is not working, you will need to explain what you have done and what results you are getting.
|
|
|
|
|
I am trying to create a ccomboboxex using createwindow function.but I get the old combobox look(3d gray).
How can I get the XP appearance combobox? Any idea? thank you.
|
|
|
|
|
It happens not only for controls you create but also for all windows.
There are several ways you can achieve this. the easiest is to include a manifest file to enable visual styles.
Manifest should have following name: appname.manifest. For example SomeApp.exe.manifest.
Include manifest file in the same directory as your executable module. That is it.
To avoid copying or including additional file in you distribution package, you can include manifest file as a resource in your project but this is a little bit more complicated.
JohnCz
MS C++ MVP
|
|
|
|
|
thank you for the anwser.
|
|
|
|
|
As JohnCz said, use a manifest file. The manifest needs to specify using the Common Control 6.0. Here's a sample (change the app name as you see fit):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.1" processorArchitecture="X86" name="KRM.Undecorate" type="win32" />
<description>Undecorate a C++ name.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
</assembly>
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
thank you for the anwser,but your way can't solve my question.
|
|
|
|
|
Strange. It is working for me...
Did you follow all steps?
Perhaps if you explained all steps you have taken it would explain why it does not work.
What is the name of your application?
What is the name of your manifest file.
Did you copy manifest text from Karl’s post?
Directory where did placed manifest file.
JohnCz
MS C++ MVP
|
|
|
|
|
Hi,
Given a Mapped Drive i.e.'F:\' Is itpossible to recover the Server Name and Path .
Regards,
Bram van Kampen
|
|
|
|
|
I thought the information was available in the 'Netshare' API's - these days its likely to be available through WMI as well - if only a bit more convoluted to access
'g'
|
|
|
|
|
|
You also can read the RemotePath key in HKEY_CURRENT_USER\Network\DRIVE_LETTER to get the mapping information
|
|
|
|
|
Thanks for that info - filed away for future use
'G'/Remote/via Blackberry
|
|
|
|
|
Thanks.
I used this to write an "API" as follows:-
<br />
SGAPI BOOL GetUNCA(LPCSTR DriveSpec, LPSTR pstrResult,LPDWORD pcbSize){<br />
if((DriveSpec==NULL)||(pstrResult==NULL)||(pcbSize==NULL)){<br />
SetLastError(ERROR_INVALID_PARAMETER);<br />
return FALSE;<br />
}<br />
if(strlen(DriveSpec)!=3){<br />
SetLastError(ERROR_BAD_FORMAT);<br />
return FALSE;<br />
}<br />
if((DriveSpec[1]!=':')||(DriveSpec[2]!='\\')){<br />
SetLastError(ERROR_BAD_FORMAT);<br />
return FALSE;<br />
}<br />
<br />
char ch=toupper(DriveSpec[0]);<br />
if((ch<'A')||(ch>'Z')){<br />
SetLastError(ERROR_BAD_FORMAT);<br />
return FALSE;<br />
}<br />
CString SubKey="Network\\";<br />
SubKey+=ch;<br />
<br />
HKEY hkResult;<br />
if(RegOpenKeyExA(HKEY_CURRENT_USER,SubKey,NULL,NULL,&hkResult)!=ERROR_SUCCESS){<br />
<br />
SetLastError(ERROR_INVALID_CATEGORY);<br />
return FALSE;<br />
}<br />
<br />
DWORD Type=REG_SZ;<br />
DWORD dwRes=RegQueryValueExA(hkResult,"RemotePath",NULL,&Type,(LPBYTE)pstrResult,pcbSize);<br />
RegCloseKey(hkResult);<br />
<br />
if(dwRes==ERROR_SUCCESS)return TRUE;<br />
<br />
SetLastError(ERROR_INVALID_CATEGORY);<br />
<br />
return FALSE;<br />
}<br />
One of the Things is: How do those Subkeys Translate in Foreign Languages... ???
Thanks A lot for the Info
Bram van Kampen
|
|
|
|
|
hmmm!
GetUNC is a Commandline Utility. Maybe as a Last Resort.
Thanks for your comment though.
Regards,
Bram van Kampen
|
|
|
|
|
the CNetservice I showed from CodeGuru is NOT a command line utility - why would I have shown you something sooo useless, hmmmm ???
If you look for CNetService by Jay Wheeler, and get the download, you'll see GetUNC() uses APU WNetGetUniversalName
I was thinking one of is crazy, glad its not me, ok, for once
'g'
|
|
|
|
|
Hi,
Garth J Lancaster wrote: the CNetservice I showed from CodeGuru is NOT a command line utility - why would I have shown you something sooo useless, hmmmm ??
Well, that's what the link appeared to be pointed to. I asked myself the same question.
Garth J Lancaster wrote: If you look for CNetService by Jay Wheeler, and get the download, you'll see GetUNC() uses APU WNetGetUniversalName
I was thinking one of is crazy, glad its not me, ok, for once
Well maybe the gremlins...
Found that site, its very usefull.
Thanks.
Bram van Kampen
|
|
|
|
|
|
Bingo!
Just the Ticket. Thanks.
As a Side Line, The MS Windows API is growing that wide that even googeling, or MSDN becomes difficult, if you don't remember the name of an API in the first place. Many of the 10,000 or so Microsoft engineers seem to be having the same problem. They have another weapon though, access to the windows code, and it occurs to me that if they cannot find quikly what they need, that they just introduce another API to add to the pile.
In the mean time I wrote:
<br />
SGAPI BOOL GetUNC(LPCSTR DriveSpec, LPSTR pstrResult,LPDWORD pcbSize)<br />
based on the previous replies. That was not difficult, but WNetGetUniversalName() is more universal, and less likely to break in future versions.
Thanks,
Bram van Kampen
|
|
|
|
|
rats - he beat me to it - see my prev response - lest you got there in the end - have fun
'g'
|
|
|
|