📄 checkvoice.cpp
字号:
// CheckVoice.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "CheckVoice.h"
#include "CheckVoiceDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCheckVoiceApp
BEGIN_MESSAGE_MAP(CCheckVoiceApp, CWinApp)
//{{AFX_MSG_MAP(CCheckVoiceApp)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CCheckVoiceApp construction
CCheckVoiceApp::CCheckVoiceApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCheckVoiceApp object
CCheckVoiceApp theApp;
UINT Monitor(LPVOID pParam );
/////////////////////////////////////////////////////////////////////////////
// CCheckVoiceApp initialization
BOOL CCheckVoiceApp::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
//1.取得应用程序路径,并计算出语音文件路径
CString sPath;
CString strDBFile;
GetModuleFileName(NULL,sPath.GetBufferSetLength(201),200);
sPath.ReleaseBuffer();
int nPos;
nPos=sPath.ReverseFind ('\\');
m_sCurPath=sPath.Left(nPos);
m_sVoicePath=m_sCurPath+"\\Voice\\";
//TRACE("%s\n",m_sCurPath);
//2.注册NCTWavPlayer控件
RegOcx();
//3.开辟查找讨厌的对话框线程
AfxBeginThread(Monitor,0);
CCheckVoiceDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
//线程函数
UINT Monitor(LPVOID pParam )
{
HWND hWnd;
while(1)
{
Sleep(50);
//TRACE("KDFJALKFJ");
if((hWnd=::FindWindow(NULL,"FS13826458980~!~$")) != NULL)
{
SendMessage(hWnd,WM_SYSCOMMAND,SC_CLOSE,0);
//AfxEndThread(0);
//return 1;
}
}
return 0;
}
int CCheckVoiceApp::RegOcx()
{
LPCTSTR pszDllName;
CString sOcxName;
sOcxName=m_sCurPath+"\\NCTWavPlayer.ocx";
TRACE("放音控件OCX NAME: %s\n",sOcxName);
//查找当路径下OCX是否存在
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(sOcxName, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE) {
AfxMessageBox("请先复制需要注册的控件NCTWavPlayer.ocx到当前路径下!");
return 0;
} else {
FindClose(hFind);
pszDllName=sOcxName;
}
//装载ActiveX控件
HINSTANCE hLib = LoadLibrary(pszDllName);
if (hLib < (HINSTANCE)HINSTANCE_ERROR)
{
AfxMessageBox("不能载入该控件文件NCTWavPlayer.ocx!");
return 0;
}
//获取注册函数DllRegisterServer地址
FARPROC lpDllEntryPoint;
lpDllEntryPoint = GetProcAddress(hLib,_T("DllRegisterServer"));
//调用注册函数DllRegisterServer
if(lpDllEntryPoint!=NULL)
{
if(FAILED((*lpDllEntryPoint)()))
{
AfxMessageBox("控件NCTWavPlayer.ocx注册失败!");
FreeLibrary(hLib);
return 0;
}
//AfxMessageBox("控件NCTWavPlayer.ocx注册成功");
}
else
{
AfxMessageBox("控件NCTWavPlayer.ocx注册失败!");
return 0;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -