mfc - How can I show the computers operating system in C++? -


i making mfc dialog based application , function read data project , pc , copy data clipboard. have code needed transfer data external project, little stuck on how going operating system data , copy data clipboard.

this code have far.

void cbugsdlg::onbnclickedbtncopy() {     cversiontranslatomatic ver(::getdesktopwindow());      cstring version = ver.getmajorminorversionstring() + " " +              ver.getversiontype() + " " + ver.getbuildnumber() + " " +             ver.getservicepack();      hglobal hglbcopy;      if( openclipboard()){                emptyclipboard();         wchar_t *wcbuffer = 0;         hglbcopy = globalalloc(gmem_moveable,                 (version.getlength() + 1)*sizeof(wchar_t));          wcbuffer = (wchar_t*)globallock(hglbcopy);         lstrcpy(wcbuffer, version);         globalunlock(hglbcopy);         setclipboarddata(cf_unicodetext, hglbcopy);         closeclipboard();     } } 

any appreciated.

using window apis can fetch following os data-

  1. os version (osversioninfoex osvi)
  2. os system info (system_info si)

and suppose following code produce os data needed-

// added following 2 function pointers support below code typedef void (winapi *pgetsysteminfo)(lpsystem_info); typedef bool (winapi *pgetproductinfo)(dword, dword, dword, dword, pdword);     osversioninfoex osvi;    system_info si;    pgetsysteminfo pgetsysteminfo;    pgetproductinfo pgetproductinfo;    bool bosversioninfoex;    dword dwtype;     zeromemory(&si, sizeof(system_info));    zeromemory(&osvi, sizeof(osversioninfoex));     osvi.dwosversioninfosize = sizeof(osversioninfoex);     if( !(bosversioninfoex = getversionex ((osversioninfo *) &osvi)) )       return 1;     // call getnativesysteminfo if supported or getsysteminfo otherwise.     pgetsysteminfo = (pgetsysteminfo ) getprocaddress(       getmodulehandle(text("kernel32.dll")),        "getnativesysteminfo");    if(null != pgetsysteminfo)       pgetsysteminfo(&si);    else getsysteminfo(&si); 

this code should integrated mfc project.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -