⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time.c

📁 执行和去除共享软件日期限制的程序
💻 C
字号:
#include <user\dlg.h>
#include "sharewareluncher.h"
#include "time1.h"
#include "tab.h"
#include "resource.h"

extern HINSTANCE hInst;
HBITMAP hbmHHour[3],hbmLHour[10],hbmHMin[6],hbmLMin[10];
HBITMAP hbmHSec[6],hbmLSec[10],hbmClockBkg;
extern HBITMAP hbmMain,hbmClock;
extern HWND hMainWnd;
extern DWORD dwThreadId;
extern BOOL bMined,bQuit;
extern int nTimerNum;
extern TIMERINFO ti[10];
extern BOOL bClockYes;
BOOL bCanGo=TRUE;
extern int nAlarmEveryHour;
BOOL bKnocked=FALSE;
int nDlgflag=-99;
extern char szerr[1100];
extern BOOL bNoShowDel,btRuning;
extern BOOL bHelp;

const char szver[400]="   版本:1.2\x0d\x0a    本软件是一个程序发射器兼闹钟程式并可虚拟软驱\
,可使你的共享软件永不过期。只要你在程序设置中设定好共享软件的启动日期(在其有效期内),则本程式\
启动该共享软件时会先把系统日期改为该有效日期,20秒后自动改回当前日期。为防系统日期混乱\
导致共享软件启动失败,请勿在20秒内启动两个或以上的共享软件。\x0d\x0a    本软件自带整点";
const char szver1[200]="报时功能,必须有声卡支持。如到时声卡正在使用中则无法报时。(PCI声卡除外)。\
\x0d\x0a    为NT系统安全性起见,本软件的关机及修改系统日期功能在Windows NT中不起作用。\x0d\x0a";
const char szver2[100]="谢谢你对本软件的支持。\x0d\x0a作者联系地址:常熟市花园浜路2#308\x0d\x0a邮编:215500\
\x0d\x0a电话:0520-2798715\x0d\x0a";
const char szver3[40]="E-Mail:SZ7301@public1.sz.js.cn";

void InitTimeBmp(HWND hWnd)
{
	HDC hDC,hMainDC,hMemDC,hBkgDC,hMaskDC,hTempDC;
   HBITMAP hbmMask;
   int i,j;

   hDC=GetDC(hWnd);
   hMemDC=CreateCompatibleDC(hDC);
   hMainDC=CreateCompatibleDC(hDC);
   hTempDC=CreateCompatibleDC(hDC);
   hMaskDC=CreateCompatibleDC(hDC);
   hBkgDC=CreateCompatibleDC(hDC);
   hbmClockBkg=CreateCompatibleBitmap(hDC,168,42);
   hbmMask=CreateCompatibleBitmap(hDC,180,38);

   SelectObject(hMemDC,hbmClock);
   SelectObject(hMainDC,hbmMain);
   SelectObject(hMaskDC,hbmMask);
   SelectObject(hBkgDC,hbmClockBkg);

   BitBlt(hBkgDC,0,0,168,42,hMainDC,10,54,SRCCOPY);
   BitBlt(hMaskDC,0,0,180,38,hMemDC,0,0,WHITENESS);

   for(i=0;i<180;i++)
   {
   	for(j=0;j<38;j++)
      {
      	if(GetPixel(hMemDC,i,j)!=0x00000000)
         	SetPixelV(hMaskDC,i,j,0x00ffffff);
      }
   }

	for(i=0;i<3;i++)
   {
      hbmHHour[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmHHour[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,2,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }
   for(i=0;i<6;i++)
   {
      hbmHMin[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmHMin[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,62,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }
   for(i=0;i<6;i++)
   {
      hbmHSec[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmHSec[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,124,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }
   for(i=0;i<10;i++)
   {
      hbmLHour[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmLHour[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,24,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }
   for(i=0;i<10;i++)
   {
      hbmLMin[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmLMin[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,84,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }
   for(i=0;i<10;i++)
   {
      hbmLSec[i]=CreateCompatibleBitmap(hDC,18,38);
   	SelectObject(hTempDC,hbmLSec[i]);

      BitBlt(hTempDC,0,0,18,38,hBkgDC,144,0,SRCCOPY);
      BitBlt(hTempDC,0,0,18,38,hMaskDC,0,0,SRCAND);
		BitBlt(hTempDC,0,0,18,38,hMemDC,i*18,0,SRCPAINT);
   }

	DeleteDC(hMemDC);
   DeleteDC(hMainDC);
   DeleteDC(hMaskDC);
   DeleteDC(hBkgDC);
   DeleteDC(hTempDC);
   ReleaseDC(hWnd,hDC);
}

void ShowTime(HWND hWnd)
{
	SYSTEMTIME stTime;
   HDC hDC,hMemDC,hNoDC;

   hDC=GetDC(hWnd);
   hMemDC=CreateCompatibleDC(hDC);
	//hTempDC=CreateCompatibleDC(hDC);
   hNoDC=CreateCompatibleDC(hDC);

   SelectObject(hMemDC,hbmClockBkg);
   //SelectObject(hMemDC,hbmClock);

   GetLocalTime(&stTime);

   SelectObject(hNoDC,hbmHHour[stTime.wHour/10]);
   BitBlt(hMemDC,2,2,18,38,hNoDC,0,0,SRCCOPY);
   SelectObject(hNoDC,hbmLHour[stTime.wHour%10]);
   BitBlt(hMemDC,24,2,18,38,hNoDC,0,0,SRCCOPY);
   SelectObject(hNoDC,hbmHMin[stTime.wMinute/10]);
   BitBlt(hMemDC,62,2,18,38,hNoDC,0,0,SRCCOPY);
   SelectObject(hNoDC,hbmLMin[stTime.wMinute%10]);
   BitBlt(hMemDC,84,2,18,38,hNoDC,0,0,SRCCOPY);
   GetLocalTime(&stTime);
   SelectObject(hNoDC,hbmHSec[stTime.wSecond/10]);
   BitBlt(hMemDC,124,2,18,38,hNoDC,0,0,SRCCOPY);
   SelectObject(hNoDC,hbmLSec[stTime.wSecond%10]);
   BitBlt(hMemDC,144,2,18,38,hNoDC,0,0,SRCCOPY);

   BitBlt(hDC,10,54,168,42,hMemDC,0,0,SRCCOPY);

   DeleteDC(hMemDC);
   //DeleteDC(hTempDC);
   DeleteDC(hNoDC);
   ReleaseDC(hWnd,hDC);
}

#pragma argsused
DWORD TimeThread(INT nUnused)
{
	SYSTEMTIME st;
   WORD wSec;

   SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_LOWEST);

   GetLocalTime(&st);
   wSec=st.wSecond;

   while(!bQuit)
   {
      if(!bMined)
   	{
      	GetLocalTime(&st);

      	if(st.wSecond!=wSec)
      	{
      		wSec=st.wSecond;
      		ShowTime(hMainWnd);
      	}
      }
      Sleep(100);
   }

   return 100;
}

#pragma argsused
DWORD KlockThread(INT nUnused)
{
	SYSTEMTIME st;
   int i;

   SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_LOWEST);

   while(!bQuit)
   {
      GetLocalTime(&st);

      if(nAlarmEveryHour==1)
      {
      	if(st.wMinute==0 && !bKnocked)
      	{
         	int j;

         	if(st.wHour>=13)
         		j=(int)(st.wHour-12);
         	else if(st.wHour==0)
         		j=12;
         	else
         		j=(int)st.wHour;

         	PlayWav(MAKEINTRESOURCE(IDW_START));
         	for(i=0;i<j;i++)
         	{
         		PlayWav(MAKEINTRESOURCE(IDW_GO));
         	}
         	bKnocked=TRUE;
      	}
      	else if(st.wMinute==30 && !bKnocked)
      	{
      		PlayWav(MAKEINTRESOURCE(IDW_START));
         	PlayWav(MAKEINTRESOURCE(IDW_GO));
         	bKnocked=TRUE;
      	}
      	else if(st.wMinute!=0 && st.wMinute!=30)
      		bKnocked=FALSE;
      }

      for(i=0;i<nTimerNum;i++)
      {
      	if(ti[i].wHour==st.wHour && ti[i].wMinute==st.wMinute && bClockYes)
			{
         	SendMessage(hMainWnd,MYWM_TIMEUP,i,0);
            Sleep(61000);
         }
      }
      Sleep(1000);
   }

   return 101;
}

void TimeUp(HWND hWnd,int x)
{
	bCanGo=FALSE;
   ShowWindow(hWnd,SW_RESTORE);
   SetForegroundWindow(hWnd);
   nDlgflag=x;
   MessageBeep(MB_ICONHAND);
   DialogBox(hInst,MAKEINTRESOURCE(IDD_SHOWHELP),hWnd,(DLGPROC)DlgHelpProc);
   nDlgflag=-99;
}

void PlayWav(LPSTR lpFileName)
{	PlaySound(lpFileName,hInst,SND_RESOURCE | SND_NOWAIT);}

#pragma argsused
BOOL APIENTRY DlgHelpProc(HWND hWnd,UINT uMsg,UINT wParam,LONG lParam)
{
   char s[30];

	switch(uMsg)
   {
   	case WM_INITDIALOG:
         if(bHelp)
         	SetDlgItemText(hWnd,IDCANCEL,"取  消");
         else
         {
         	SetDlgItemText(hWnd,IDCANCEL,"关闭计算机");
            if(OSType()==NT)
         	{         		HWND hw;            	hw=GetDlgItem(hWnd,IDCANCEL);            	EnableWindow(hw,FALSE);            }         }

      	if(nDlgflag==-99)
         {
         	LoadString(hInst,IDS_VER,szerr,1000);

            szerr[45]=0xD7;
            szerr[46]=0xF7;
            szerr[47]=0xD5;
            szerr[48]=0xDF;
            szerr[49]=0xA3;
            szerr[50]=0xBA;
				szerr[51]=0xC2;
            szerr[52]=0xAC;
            szerr[53]=0xB7;
            szerr[54]=0xE3;
            szerr[55]='\0';

            strcat(szerr,szver);
            strcat(szerr,szver1);
            strcat(szerr,szver2);
            strcat(szerr,szver3);
            SetWindowText(hWnd,"版权说明");
            SetDlgItemText(hWnd,IDC_INFO,szerr);
         }
         else
         {
            wsprintf(s,"现在时间是%d点%d分",ti[nDlgflag].wHour,ti[nDlgflag].wMinute);
         	SetWindowText(hWnd,s);
         	SetDlgItemText(hWnd,IDC_INFO,ti[nDlgflag].szInfo);
         }
         break;
      case WM_COMMAND:
      	switch(LOWORD(wParam))
         {
            case IDOK:
            	if(nDlgflag!=-99)
	            {
   	         	if(ti[nDlgflag].nflag==0)
      	         {
         	         nTimerNum--;
            	      bNoShowDel=TRUE;
            			ListDel1(nDlgflag);
               		WriteTimerInfo();
	               }
   	         }
               bHelp=FALSE;
      	      bCanGo=TRUE;
         		EndDialog(hWnd,TRUE);
         		return TRUE;
            case IDCANCEL:
            	if(nDlgflag!=-99)
	            {
   	         	if(ti[nDlgflag].nflag==0)
      	         {
         	         nTimerNum--;
            	      bNoShowDel=TRUE;
            			ListDel1(nDlgflag);
               		WriteTimerInfo();
	               }
   	         }
               bCanGo=TRUE;
            	if(bHelp)
               {
                  bHelp=FALSE;
               	EndDialog(hWnd,TRUE);
         			return TRUE;
               }
               else
               {
               	EndDialog(hWnd,TRUE);
         			ExitWindowsEx(EWX_SHUTDOWN,0);
                  return TRUE;
               }
         }
         break;
      case WM_CLOSE:
			EndDialog(hWnd,TRUE);
         return TRUE;
   }
   return FALSE;
}

void DelTempTimer(void)
{
	int i,j,k,c[10]={0,0,0,0,0,0,0,0,0,0};
   HKEY  hKey1;//, hKey2;
  	DWORD  dwDisposition;
  	//DWORD dwFlag=(DWORD)nTimerNum,dwDateSize=sizeof(DWORD);
   char sz[150];

   for(i=0,j=0,k=0;i<nTimerNum;i++)
   {
   	if(ti[i].nflag!=0)
      {
      	c[k]=i;
         k++;
         j++;
      }
   }

   k=nTimerNum;
   nTimerNum=j;

   for(i=0;i<nTimerNum;i++)
   {
		ti[i]=ti[c[i]];
   }

   RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\phonix\\sharewareluncher",0, NULL, REG_OPTION_NON_VOLATILE,
                           KEY_ALL_ACCESS,NULL,&hKey1,&dwDisposition);

   for(i=0;i<k;i++)
   {
		wsprintf(sz,"TimerHour%d",i);
	   RegDeleteValue(hKey1,sz);
   	wsprintf(sz,"TimerMinute%d",i);
	   RegDeleteValue(hKey1,sz);
   	wsprintf(sz,"TimerChar%d",i);
	   RegDeleteValue(hKey1,sz);
   	wsprintf(sz,"Timerflag%d",i);
	   RegDeleteValue(hKey1,sz);
   }
   WriteTimerInfo();
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -