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

📄 changewallet.cpp

📁 自动壁纸更换器源码-更换器主程序 实现你的闷响 想换就换
💻 CPP
字号:
// changewallet.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "changewallet.h"
#include "changewalletDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChangewalletApp

BEGIN_MESSAGE_MAP(CChangewalletApp, CWinApp)
	//{{AFX_MSG_MAP(CChangewalletApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChangewalletApp construction

CChangewalletApp::CChangewalletApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CChangewalletApp object

CChangewalletApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CChangewalletApp initialization

BOOL CChangewalletApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CChangewalletDlg dlg;
	//m_pMainWnd = &dlg;
	//int nResponse = dlg.DoModal();
    HKEY hresult;
	LONG x;
	CString frequency;
	CFileFind find;
	BOOL bfind;
	CString directory_xu_temp;
	DWORD i=0;
    CString directory;
	CString done;
    DWORD len = 0;
	DWORD current;
    DWORD type = 0;
	DWORD date=0;
	DWORD date1=0;
	DWORD current_date=0;
	DWORD current_date1=0;
	DWORD sum=0;
    LPDWORD temp1;
	LPDWORD sum_temp;
	LPDWORD temp2;
	DWORD current_date_temp;
	DWORD current_month_temp;
	CTime ctime;
    current_date=ctime.GetDayOfWeek();
	current_date1=ctime.GetMonth();
	current_date_temp=ctime.GetDayOfWeek();
	temp1=&current_date_temp;
	current_month_temp=ctime.GetMonth();
	temp2=&current_month_temp;
	x=RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
			       LPCTSTR("Software\\Microsoft\\Windows\\CurrentVersion\\xu"),
		           0,
                   KEY_ALL_ACCESS, 
                   &hresult);
	if(ERROR_SUCCESS==x)
	{
	       x=RegQueryValueEx(hresult,LPCTSTR("walletdirectory"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_SZ)
		   {
                char* data_temp1 = new char[len];
				x=RegQueryValueEx(hresult,LPCTSTR("walletdirectory"),
					              NULL,NULL,
								  (unsigned char *)data_temp1,
								  &len);
				directory=data_temp1;
		   }
           x=RegQueryValueEx(hresult,LPCTSTR("done"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_SZ)
		   {
                char* data_temp1 = new char[len];
				x=RegQueryValueEx(hresult,LPCTSTR("done"),
					              NULL,NULL,
								  (unsigned char *)data_temp1,
								  &len);
				done=data_temp1;
		   }
		   x=RegQueryValueEx(hresult,LPCTSTR("frequency"),NULL,
			                 &type,NULL,
							 &len);
		   char *data_temp=new char[len];
		   if(type==REG_SZ)
		   {
			   
			   x=RegQueryValueEx(hresult,LPCTSTR("frequency"),
				                 NULL,NULL,
								 (unsigned char *)data_temp,
								 &len);
			   frequency=data_temp;
		   }
           x=RegQueryValueEx(hresult,LPCTSTR("current"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_DWORD) 
		   {
			   DWORD valueLen = sizeof(current);
			   x=RegQueryValueEx(hresult,LPCTSTR("current"),
				                 NULL,NULL,
                                 (unsigned char *)&current,&valueLen);
		   }
           x=RegQueryValueEx(hresult,LPCTSTR("date"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_DWORD)
		   {
               DWORD valueLen = sizeof(date);
			   x=RegQueryValueEx(hresult,LPCTSTR("date"),
				                 NULL,NULL,
                                 (unsigned char *)&date,&valueLen);
		   }
           x=RegQueryValueEx(hresult,LPCTSTR("date1"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_DWORD)
		   {
               DWORD valueLen = sizeof(date1);
			   x=RegQueryValueEx(hresult,LPCTSTR("date1"),
				                 NULL,NULL,
                                 (unsigned char *)&date1,&valueLen);
		   }
		   x=RegQueryValueEx(hresult,LPCTSTR("sum"),NULL,
			                 &type,NULL,
							 &len);
		   if(type==REG_DWORD) 
		   {
			   DWORD valueLen = sizeof(sum);
			   x=RegQueryValueEx(hresult,LPCTSTR("sum"),
				                 NULL,NULL,
                                 (unsigned char *)&sum,&valueLen);
		   }
		   if(frequency=="week")
		   {
	             if(current_date==date)
				 {
					 if(done=="false")
					 {
					     change(directory,current,sum);
                         current=current+1;
                         x=RegSetValueEx(hresult,LPCTSTR("done"),
				                         0,
				                         REG_SZ,
                                         (const BYTE *)(LPCTSTR)"true",
							             4);
					 }
				 }
				 else 
				 {
                    x=RegSetValueEx(hresult,LPCTSTR("done"),
				                         0,
				                         REG_SZ,
                                         (const BYTE *)(LPCTSTR)"false",
							             5);
				 }
		   }
		   else if(frequency=="day")
		   {
			     x=RegSetValueEx(hresult,LPCTSTR("date"),
				                     0,
				                     REG_DWORD,
                                     (unsigned char *)temp1,
							          sizeof(date));   
			     switch (date)
				 {
				 case 7:
					 if(current_date==1)
					 {
						 change(directory,current,sum);
                         current=current+1;
					 }
				     break;
				 default:
                     if(current_date-1==date)
					 {
						 change(directory,current,sum);
                         current=current+1;
					 }
				 }
		   }
		   else if(frequency=="month")
		   {
                  x=RegSetValueEx(hresult,LPCTSTR("date1"),
				                     0,
				                     REG_DWORD,
                                     (unsigned char *)temp2,
							          sizeof(date));   
			      switch(date1)
				  {
				  case 12:
					  if(current_date1==1)
					  {
						  change(directory,current,sum);
                          current=current+1;
                          x=RegSetValueEx(hresult,LPCTSTR("done"),
				                         0,
				                         REG_SZ,
                                         (const BYTE *)(LPCTSTR)"true",
							             5);
					  }
					  break;
				  default:
					  if(current_date1-1==date1)
					  {
						  change(directory,current,sum);
					      current=current+1;
					  }
				  }
		   }
           else
		   {
			   change(directory,current,sum);
			   current=current+1;
		   }
		   LPDWORD temp_current;
		   if(current==sum+1)
		   {
	           current=0;
		   }
		   temp_current=&current;
           x=RegSetValueEx(hresult,LPCTSTR("current"),
				             0,
				             REG_DWORD,
                             (unsigned char *)temp_current,
							 sizeof(current));
		   directory_xu_temp=directory+"\\*.bmp";
		   bfind=find.FindFile(directory_xu_temp);
		   if(bfind&&find.FindNextFile())
		   {
			   while(bfind)
			   {
				   i=i+1;
				   bfind=find.FindNextFile();
			   }
		   }
           sum_temp=&i;
           x=RegSetValueEx(hresult,LPCTSTR("sum"),
				                 0,
				                 REG_DWORD, 
                                 (unsigned char*)sum_temp,
							      sizeof(sum_temp));
		   RegCloseKey(hresult);
	}
	return FALSE;
}

void CChangewalletApp::change(CString temp_directory,DWORD temp_current,DWORD temp_sum)
{
    CFileFind find;
	BOOL bfind;
	BOOL xu;
	int i=0;
	CString filename;
	temp_directory+="\\*.bmp";
	bfind=find.FindFile(temp_directory);
		   if(bfind&&find.FindNextFile())
		   {
			   while(bfind)
			   {
				  if(i==temp_current)
				  {
                      filename=find.GetFilePath();
					  xu=SystemParametersInfo(SPI_SETDESKWALLPAPER,0,(void *)(LPCTSTR)filename,
						                    SPIF_UPDATEINIFILE);
					  break;
				  }
                  i=i+1;
				  bfind=find.FindNextFile();
				   
				}
		   }
}

⌨️ 快捷键说明

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