Friday, April 27, 2012

Register a file

#include <iostream>
#include <windows.h>
#include <conio.h>
#pragma comment(lib, "user32.lib")

using namespace std;

#define BUFFER 32750



void getValues();
void filesApp();

int main()
{
    filesApp();
    getValues();
    getch();
    return 0;
}

void getValues()
{
    char lpbuffer[BUFFER];
    DWORD lpnsize = BUFFER;
    SYSTEM_INFO sysinfo;

    GetComputerName(lpbuffer, &lpnsize);
    GetSystemInfo(&sysinfo);

    cout << "Name:"<< " " << lpbuffer << endl;
    cout << "Number of processors:"<< " " << sysinfo.dwNumberOfProcessors<< endl;
    cout << "Maxmum app address:"<< " " << sysinfo.lpMaximumApplicationAddress << endl;
    //getchar();
}

void filesApp()
{
    char spath[MAX_PATH];
    char lpbuffer[MAX_PATH];

    GetModuleFileName(NULL, spath, MAX_PATH);
    GetWindowsDirectory(lpbuffer, MAX_PATH);
    cout << spath << endl;
    cout << lpbuffer << endl;

    char newfile[] = "C:\\Documents and Settings\\user\\Desktop\\dir\\jokeEx.exe";

    CopyFile(spath, newfile, false);

    LPCTSTR subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
    HKEY hkey;
    string progName = newfile;
    int proglen = progName.size() + 1;
    long key = RegOpenKeyEx(HKEY_CURRENT_USER,
                             subkey,
                             0,
                             KEY_READ | KEY_WRITE,
                             &hkey  );
    if(key == ERROR_SUCCESS)
    {
        long qkey = RegQueryValueEx(hkey,
                                    "jokeEx",
                                    NULL,
                                    NULL,
                                    NULL,
                                    NULL);
         if(qkey == ERROR_FILE_NOT_FOUND)
         {
             long skey = RegSetValueEx(hkey,
                                       "jokeEx",
                                       0,
                                       REG_SZ,
                              (const BYTE*)progName.c_str(),
                                       proglen);
         }
         else
         {
             cout << "file exists" << endl;
          }

    }

    cout << "---------------------" << endl;
}




How to create Custom push button in QT5

To be honest this is not my work its an exact copy from this link. http://mcmtechtips.blogspot.com/2012/03/shape-qpushbutton-in-your-own-st...