The following uses QQ as an example:
# Include <iostream> # include <windows. h> using namespace STD; # define rtn_error 13int main (void) {# define my_bufsize 132 // arbitrary initial value. // dynamic allocation will be used. hkey; tchar szproducttype [my_bufsize]; DWORD dwbuflen = my_bufsize; long LRET; // open the registry below. Other operations can be performed only after the registry is opened. LRET = regopenkeyex (HKEY_LOCAL_MACHINE, // text ("SOFTWARE \ Tencent \ qq2009") of the Root Key to be opened, // the subkey 0 to be opened, // This must be 0 Key_query_value, // specify the open mode, which is read & hkey); // return the handle if (LRET! = Error_success) // determines whether the server is successfully opened. Return 1; // The following LRET = regqueryvalueex (hkey, // The handle text ("Install") returned when the registry is opened "), // The name to be queried. The QQ installation directory record is null. // It must be null or 0 null, (lpbyte) szproducttype, // put what we want here & dwbuflen); If (LRET! = Error_success) // determines whether the query is successful. Return 1; regclosekey (hkey); cout <(char *) szproducttype; strcat (szproducttype, "\ bin \ QQ. EXE "); winexec (szproducttype, sw_show );}