Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

C++ cout operating system


  • Please log in to reply
6 replies to this topic

#1 thisisu

thisisu

  • Malware Response Team
  • 2,525 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:10:18 PM

Posted 27 October 2012 - 03:48 PM

#include <iostream>
#include <ctime>
#include <windows.h>
using namespace std;

int main ()
{
  cout << "Getting information about your operating system. Please wait.\n";

  BOOL WINAPI GetVersionEx(
  _Inout_  LPOSVERSIONINFO lpVersionInfo
);

  return 0;
}

Pretty simple question I suppose, how do I get the output of what:

BOOL WINAPI GetVersionEx(
  _Inout_  LPOSVERSIONINFO lpVersionInfo
);

found / detected using cout or by appending the detection into a log file (fout?)

Thanks :)

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:18 PM

Posted 28 October 2012 - 03:14 AM

Well, you write the values in the structure. There's no built-in "print the operating system information" function. You have a struct with values inside, you need to write code to print those values however you see fit.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 thisisu

thisisu
  • Topic Starter

  • Malware Response Team
  • 2,525 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:10:18 PM

Posted 28 October 2012 - 05:38 PM

Hi Billy,

Thanks for your response but I'm afraid I do not understand.. :( I'm going to read some more tutorials.

#4 Romeo29

Romeo29

    Learning To Bleep


  • BC Advisor
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:11:18 PM

Posted 29 October 2012 - 04:50 AM

Something like this :
#include <iostream>
#include <ctime>
#include <windows.h>
using namespace std;

int main ()
{
 OSVERSIONINFOEX osinfo;

cout << "Getting information about your operating system. Please wait.\n";

ZeroMemory(&osinfo, sizeof(OSVERSIONINFOEX));
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

if(GetVersionEx((OSVERSIONINFO*)&osinfo)!=0){
   if(osinfo.dwMajorVersion==6 && osinfo.dwMinorVersion==1 ) cout << "You are using Windows 7";
}

  return 0;
}

For more information : http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833%28v=vs.85%29.aspx

#5 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:09:18 PM

Posted 29 October 2012 - 11:48 AM

Yep, something like that. :)

Of course you can write things out as numbers too -- operator << works with integers (like the bits inside the OSVERSIONINFOEX structure).

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#6 Romeo29

Romeo29

    Learning To Bleep


  • BC Advisor
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:11:18 PM

Posted 29 October 2012 - 12:37 PM

Ahh! Billy you are genius! I had to read it twice to see what you meant :)

#7 thisisu

thisisu
  • Topic Starter

  • Malware Response Team
  • 2,525 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:10:18 PM

Posted 30 October 2012 - 12:30 AM

Thanks to you both :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users