ITPub博客

首页 > 数据库 > 数据库开发技术 > PLSQL8.0自动加载器源码

PLSQL8.0自动加载器源码

原创 数据库开发技术 作者:cbcgorilla 时间:2009-10-14 12:42:57 0 删除 编辑

// PLSQLConsoleLoader.cpp : PLSQL8.0自动加载器

//主要功能:保持PLSQL的试用期为30天不变.
//
// Author: Michael 2009-10-14
////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include
#include
using namespace std;

DWORD DeleteTree(HKEY RootKey, const char *pSubKey)
{

HKEY hKey;
DWORD nRet;
DWORD NameCnt,NameMaxLen;
DWORD KeyCnt,KeyMaxLen,MaxDateLen;
static char sFormat[256] = "";
strcat(sFormat, "----");

static int dwDeep = -1;
dwDeep++;

nRet=RegOpenKeyEx(RootKey,pSubKey,0,KEY_ALL_ACCESS,&hKey);
if(nRet!=ERROR_SUCCESS)
{
cout<<"can't open the regedit";
return 0;
}

nRet = RegQueryInfoKey(hKey,NULL,NULL,NULL,&KeyCnt,&KeyMaxLen,NULL,&NameCnt,
&NameMaxLen,&MaxDateLen,NULL,NULL);
if(nRet == ERROR_SUCCESS)
{
for(int dwIndex = KeyCnt - 1; dwIndex >= 0; dwIndex--) //枚举键值
{
char sKeyName[256] = "";
RegEnumKey(hKey, dwIndex, sKeyName, sizeof(sKeyName));

HKEY hKeySub;
DWORD KeyCntSub;
char pSubKeyTemp[256] = "";
strcpy(pSubKeyTemp, pSubKey);
strcat(pSubKeyTemp, "");
strcat(pSubKeyTemp, sKeyName);

nRet = RegOpenKeyEx(RootKey,pSubKeyTemp,0,KEY_ALL_ACCESS,&hKeySub);
if(nRet == ERROR_SUCCESS)
{
nRet = RegQueryInfoKey(hKeySub,NULL,NULL,NULL,&KeyCntSub,&KeyMaxLen,NULL,&NameCnt,
&NameMaxLen,&MaxDateLen,NULL,NULL);
if(nRet == ERROR_SUCCESS)
{
if (KeyCntSub != 0)
{
DeleteTree(RootKey, pSubKeyTemp);
}
RegCloseKey(hKeySub);
}
}

// cout << sFormat << sKeyName << endl;

RegDeleteKey(RootKey ,pSubKeyTemp);
}

RegCloseKey(hKey);
}

// sFormat[strlen(sFormat) - 4] = 0;

if (dwDeep == 0)
{
RegDeleteKey(RootKey ,pSubKey);
}

return 0;
}

int main(int argc, char* argv[])
{
DeleteTree(HKEY_CURRENT_USER, "SoftwareAllround Automations");
DeleteTree(HKEY_CURRENT_USER, "SoftwareMicrosoftSecurity");

char chPath[301];
::GetCurrentDirectory(300,(LPTSTR)chPath);//得到当前目录
char path[200]= "plsqldev.exe";
strcat(chPath,path);
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &pi, sizeof(pi) );
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);

// Start the child process
if(CreateProcess(chPath, "", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
else
{
cout<<"创建失败!"< HANDLE hProcess = GetCurrentProcess();//get current process
TerminateProcess(hProcess,0); //close process
}

system("pause");
return 0;
}

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8700374/viewspace-1027839/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    7
  • 访问量
    17293