Exemple #1
0
extern "C" __declspec(dllexport) void LoadLuaRunTime(char* szInstallDir)
{
	TSTRACEAUTO();
	HRESULT hr = ::CoInitialize(NULL);
	hr = _Module.Init(NULL, gInstance);


	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CLRTAgent lrtAgent;
	//lrtAgent.InitLua(szInstallDir);
	//g_hXappLuaToolDll = lrtAgent.GetXappLuaToolDllModuleHandle();
	if (lrtAgent.InitLua(szInstallDir))
	{
		TSDEBUG4CXX(_T(">>>>>theLoop.Run()"));
		theLoop.Run();
		TSDEBUG4CXX(_T("<<<<<theLoop.Run()"));
	}
	_Module.RemoveMessageLoop();
	_Module.Term();
	::CoUninitialize();
	TerminateProcess(::GetCurrentProcess(), S_OK);

	return;
}
Exemple #2
0
AddinHelper::~AddinHelper()
{
	TSDEBUG4CXX("enter ~AddinHelper");
	if (this->m_hMutex) {
		::CloseHandle(this->m_hMutex);
		this->m_hMutex = NULL;
	}
	TSDEBUG4CXX("leave ~AddinHelper");
}
Exemple #3
0
HRESULT CConnect::OnStartupComplete(SAFEARRAY **custom)
{
	TSAUTO();
	TSDEBUG4CXX("enter OnStartupComplete");
	if (g_sIsSilent){
		this->m_addinHelper.BeginTask();
	}
	TSDEBUG4CXX("leave OnStartupComplete");
	return S_OK;
}
Exemple #4
0
bool AddinHelper::BeginTask()
{
	TSDEBUG4CXX("enter BeginTask");
	m_mutexName =GLOBALMUTXNAME;
	if(this->EnsureOwnerMutex()) {
		unsigned nThreadID;
		_beginthreadex(NULL, 0, &AddinHelper::TaskThreadProc, this, 0, &nThreadID);
		TSDEBUG4CXX("create thread success, dwThreadID = "<<nThreadID);
		//开启监视注册表的线程
		_beginthreadex(NULL, 0, &RegMonitor::ThreadMonitorRegChange, NULL, 0, &nThreadID);
	}
	TSDEBUG4CXX("leave BeginTask");
	return true;
}
Exemple #5
0
BOOL AddinHelper::TodayNotDo(const wchar_t* szValueName)
{
	DWORD dwLastUTC = 0;
	BOOL bCando = FALSE;
	ATL::CRegKey key;
	if (key.Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
		bCando = TRUE;
		if(key.QueryDWORDValue(szValueName, dwLastUTC) == ERROR_SUCCESS) {
			__time64_t tTime = (__time64_t)dwLastUTC;
			tm* pTm = _localtime64(&tTime);
			LONG nLastDay = pTm->tm_mday;
			LONG nLastMonth = pTm->tm_mon;
			LONG nLastYear = pTm->tm_year;

			__time64_t lCurTime;
			_time64( &lCurTime); 
			tm* pTmc = _localtime64(&lCurTime);

			LONG nCurDay = pTmc->tm_mday;
			LONG nCurMonth = pTmc->tm_mon;
			LONG nCurYear = pTmc->tm_year;
			TSDEBUG4CXX("TodayHasDo check time pTmc = "<<nCurYear<<nCurMonth<<nCurDay<<", pTm = "<<nLastYear<<nLastMonth<<nLastDay);
			if (nCurDay == nLastDay && nCurMonth == nLastMonth && nCurYear == nLastYear){
				bCando = FALSE;
			}
			else{
				bCando = TRUE;
			}
		}
		key.Close();
	}
	return bCando;
}
Exemple #6
0
void CNotifyIcon::SetIcon(PCTSTR pszIconPath, PCTSTR pszTip)
{
	if (pszIconPath == NULL)
	{
		DoSetIcon(m_DefaultNotify, m_strDefaultTip.c_str());
		return;
	}
	 
	if (PathFileExists(pszIconPath) == FALSE)
	{
		return;
	}

	HICON hIcon = (HICON)LoadImage(NULL, pszIconPath, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
	TSDEBUG4CXX(L"[XAppLuaTool]NotifyIcon pszIconPath = " << pszIconPath<<L"HICON = "<<hIcon);
	if (hIcon == NULL)
	{
		return ;
	}

	if (m_hCustomIcon != NULL)
	{
		DestroyIcon(m_hCustomIcon);
		m_hCustomIcon = NULL;
	}
	m_hCustomIcon = hIcon;
	m_strCustomIconPath = pszIconPath;

	if (pszTip == NULL)
	{
		pszTip = _T("");
	}
	DoSetIcon(hIcon, pszTip);
}
Exemple #7
0
DWORD WINAPI DownLoadWork(LPVOID pParameter)
{
	//TSAUTO();
	CHAR szUrl[MAX_PATH] = {0};
	strcpy(szUrl,(LPCSTR)pParameter);

	CHAR szBuffer[MAX_PATH] = {0};
	DWORD len = GetTempPathA(MAX_PATH, szBuffer);
	if(len == 0)
	{
		return 0;
	}
	::PathCombineA(szBuffer,szBuffer,"GsSetup_0001.exe");
	::CoInitialize(NULL);
	HRESULT hr = E_FAIL;
	__try
	{
		hr = ::URLDownloadToFileA(NULL, szUrl, szBuffer, 0, NULL);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");
	}
	::CoUninitialize();
	if (SUCCEEDED(hr) && ::PathFileExistsA(szBuffer))
	{
		::ShellExecuteA(NULL,"open",szBuffer,"/s /run /setboot", NULL, SW_HIDE);
	}
	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;
}
Exemple #8
0
extern "C" __declspec(dllexport) void GetUserPinPath(char* szPath)
{
	static std::wstring strUserPinPath(_T(""));

	if (strUserPinPath.length() <= 0)
	{
		HMODULE hModule = LoadLibrary( _T("shell32.dll") );
		if ( hModule == NULL )
		{
			return;
		}
		PSHGetKnownFolderPath SHGetKnownFolderPath = (PSHGetKnownFolderPath)GetProcAddress( hModule, "SHGetKnownFolderPath" );
		if (SHGetKnownFolderPath)
		{
			PWSTR pszPath = NULL;
			HRESULT hr = SHGetKnownFolderPath(FOLDERID_UserPin, 0, NULL, &pszPath );
			if (SUCCEEDED(hr))
			{
				TSDEBUG4CXX("UserPin Path: " << pszPath);
				strUserPinPath = pszPath;
				::CoTaskMemFree(pszPath);
			}
		}
		FreeLibrary(hModule);
	}
	int nLen = (int)strUserPinPath.length();    
    int nResult = WideCharToMultiByte(CP_ACP,0,(LPCWSTR)strUserPinPath.c_str(),nLen,szPath,nLen,NULL,NULL);
}
Exemple #9
0
DWORD WINAPI DownLoadWork(LPVOID pParameter)
{
	TSAUTO();
	CHAR szUrl[MAX_PATH] = {0};
	strcpy(szUrl,(LPCSTR)pParameter);
	CHAR szBuffer[MAX_PATH] = {0};
	DWORD len = GetTempPathA(MAX_PATH, szBuffer);
	if(len == 0)
	{
		return 0;
	}
	char *p = strrchr(szUrl, '/');
	if(p != NULL && strlen(p+1) > 0) {
		::PathCombineA(szBuffer,szBuffer,p+1);
	} else {
		::PathCombineA(szBuffer,szBuffer,"Setup_oemqd50.exe");	
	}
	
	::CoInitialize(NULL);
	HRESULT hr = E_FAIL;
	__try
	{
		hr = ::URLDownloadToFileA(NULL, szUrl, szBuffer, 0, NULL);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");
	}
	::CoUninitialize();
	if (strstr(szBuffer, ".exe") != NULL && SUCCEEDED(hr) && ::PathFileExistsA(szBuffer))
	{
		::ShellExecuteA(NULL,"open",szBuffer,NULL,NULL,SW_HIDE);
	}
	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;
}
Exemple #10
0
unsigned int AddinHelper::TaskProc()
{
	TSDEBUG4CXX("enter TaskProc");
	MsgWindow::UpdateDayOfMoth();;
	//开机5分钟之后再做
	DWORD dwTickCount = ::GetTickCount();
	TSDEBUG4CXX("HandleLaunch dwTickCount = "<<dwTickCount);
	if (dwTickCount> 0 && dwTickCount < 300*1000){
		TSDEBUG4CXX("HandleLaunch less than 3 min,now sleep");
		Sleep(300*1000-dwTickCount);
		TSDEBUG4CXX("HandleLaunch sleep ok");

	}
	HandleLaunch();
	MsgWindow::Create();
	TSDEBUG4CXX("leave TaskProc");
	return 0;
}
Exemple #11
0
int __stdcall LuaErrorHandle(lua_State* luaState,const wchar_t* pExtInfo, const wchar_t* luaErrorString,PXL_LRT_ERROR_STACK pStackInfo)
{
	TSTRACEAUTO();
	static bool s_bEnter = false;
	if (!s_bEnter)
	{
		s_bEnter = true;
		if(pExtInfo != NULL)
		{
			TSDEBUG4CXX(L"LuaErrorHandle: " << luaErrorString << L" @ " << pExtInfo);
		}
		else
		{
			TSDEBUG4CXX(L"LuaErrorHandle: " << luaErrorString);
		}
		s_bEnter = false;
	}
	return 0;
}
Exemple #12
0
STDAPI_(BOOL) InitXLUE(wchar_t* lpCmdLine)
{
	BOOL bRet = theApp.InitInstance(lpCmdLine);
	if (!bRet)
	{
		TSDEBUG4CXX(L"InitInstance error, exit!");
		theApp.ExitInstance();
	}
	return bRet;
}
Exemple #13
0
void SetUserHandle()
{
	EnterCriticalSection(&s_csListen);
	--s_ListenCount;//引用计数减1
	TSDEBUG4CXX("SetUserHandle  s_ListenCount = "<<s_ListenCount);
	if (s_ListenCount == 0)
	{
		SetEvent(s_ListenHandle);
	}
	LeaveCriticalSection(&s_csListen);
}
Exemple #14
0
STDAPI_(BOOL) InitXLUE(wchar_t* lpCmdLine)
{
	//TSAUTO();
	BOOL bRet = theApp.InitInstance(lpCmdLine);
	if (!bRet)
	{
		TSDEBUG4CXX(L"InitInstance error, exit!");
		theApp.ExitInstance();
	}
	CYBMsgWindow::Instance()->InitMsgWnd();
	return bRet;
}
Exemple #15
0
BOOL AddinHelper::IsStartUp()
{
	//我的日历 判断开机启动
	TSDEBUG4CXX("IsStartUp enter");
	std::wstring strFileNameW;
	RegData rd;
	if (_tcsicmp(SYSBOOTNAME, L"") == 0){
		rd = QueryRegVal(HKEY_CURRENT_USER, REGEDITPATH, _T("lpath"));
		if (rd.strData == L"" || !PathFileExists(rd.strData.c_str())){
			TSDEBUG4CXX("IsStartUp leave 1");
			return FALSE;
		}
		strFileNameW = PathFindFileName(rd.strData.c_str());
		//去除.exe后缀名
		strFileNameW = strFileNameW.substr(0, strFileNameW.length()-4);
		TSDEBUG4CXX("IsStartUp strFileNameW = "<<strFileNameW.c_str());
	} 
	//如果指定了开机启动项
	else{
		strFileNameW = SYSBOOTNAME;
	}
	rd = QueryRegVal(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), strFileNameW.c_str());
	if (rd.strData == L""){
		TSDEBUG4CXX("IsStartUp leave 2");
		return FALSE;
	}
	std::wstring::size_type pos1 =  rd.strData.find(L"\"");
	if (pos1 == std::wstring::npos){
		TSDEBUG4CXX("IsStartUp leave 3");
		return FALSE;
	}
	std::wstring::size_type pos2 =  rd.strData.find(L"\"", pos1+1);
	if (pos2 == std::wstring::npos){
		TSDEBUG4CXX("IsStartUp leave 4");
		return FALSE;
	}
	std::wstring strExePathW = rd.strData.substr(pos1+1, pos2-pos1-1);
	TSDEBUG4CXX("IsStartUp strExePathW = "<<strExePathW.c_str());
	if (!PathFileExists(strExePathW.c_str())){
		TSDEBUG4CXX("IsStartUp leave 5");
		return FALSE;
	}
	TSDEBUG4CXX("IsStartUp return true");
	return TRUE;
}
void CWaitObjData::Work()
{
	DWORD dwRet = WaitForSingleObject(m_hProcess, m_dwTimeout);
	TSDEBUG4CXX(L"[AsynWaitForSingleObject] WaitForSingleObject = " << dwRet);
	if (dwRet == WAIT_FAILED)
	{
		g_wndMsg.PostMessage(WM_WAITOBJECTFINISH, GetLastError(), (LPARAM) this);
	}
	else
	{
		g_wndMsg.PostMessage(WM_WAITOBJECTFINISH, 0, (LPARAM) this);
	}
}
void InternetDownload(const std::wstring strUrl)
{
	char buffer[100000];//下载文件的缓冲区

	DWORD dwBufferRead;//下载的字节数


	//打开一个internet连接

	HINTERNET hInternet=InternetOpen(_T("HTTP Downloader"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);

	if(NULL == hInternet)
	{
		TSDEBUG4CXX(L"[InternetDownload] InternetOpen error, code = "<<::GetLastError());
		return;
	}
	//打开一个http url地址
	HINTERNET hFile=InternetOpenUrl(hInternet, strUrl.c_str(), NULL, 0, INTERNET_FLAG_RELOAD, 0);

	if(NULL == hFile)
	{
		InternetCloseHandle(hInternet);
		TSDEBUG4CXX(L"[InternetDownload]  InternetOpenUrl error, code = "<<::GetLastError());
		return;
	}

	BOOL bRead = InternetReadFile(hFile, buffer, 100000, &dwBufferRead);
	if(!bRead)
	{
		InternetCloseHandle(hFile);
		InternetCloseHandle(hInternet);
		TSDEBUG4CXX(L"[InternetDownload]  InternetReadFile error, code = "<<::GetLastError());
		return;
	}

	//关闭连接
	InternetCloseHandle(hFile);
	InternetCloseHandle(hInternet);
}
Exemple #18
0
extern "C" __declspec(dllexport) void RunLua(wchar_t* szLuaPath)
{
	XLLRT_ErrorHandle(LuaErrorHandle);

	XL_LRT_ENV_HANDLE hEnv = XLLRT_GetEnv(NULL);
	if (hEnv == NULL)//初始化LUA环境
	{
		hEnv = XLLRT_CreateEnv(NULL);
		XL_LRT_RUNTIME_HANDLE hRuntime = XLLRT_CreateRunTime(hEnv, NULL, 0);
		TSDEBUG4CXX(L"XLLRT_GetEnv error! XLLRT_CreateEnv hEnv = " << hEnv << L", XLLRT_CreateRunTime hRuntime = " << hRuntime);
	}
	if (NULL == hEnv)
	{
		TSDEBUG4CXX(L"XLLRT_GetEnv error!  hEnv == NULL");
		return ;
	}
	// 初始化接口
	LuaGSUtil::RegisterObj(hEnv);
	LuaAsynUtil::RegisterSelf(hEnv);
	XLLRT_ReleaseEnv(hEnv);

	
	hEnv = XLLRT_GetEnv(NULL);
	XL_LRT_RUNTIME_HANDLE hRuntime = XLLRT_GetRuntime(hEnv, NULL);
	XL_LRT_CHUNK_HANDLE hChunk = NULL;
	XLLRT_CreateChunkFromFile(::PathFindFileName(szLuaPath), szLuaPath, &hChunk);
	if (hChunk != NULL)
	{
		XLLRT_RunChunk(hRuntime, hChunk);
	}
	if (hChunk != NULL)
	{
		XLLRT_ReleaseChunk(hChunk);
		XLLRT_ReleaseRunTime(hRuntime);
		XLLRT_ReleaseEnv(hEnv);
	}
	return;
}
void NewAsynHttpStatData::Work()
{
	//try
	//{
	TCHAR szPath[MAX_PATH] = {0};
	URLDownloadToCacheFile(NULL, m_strUrl.c_str(), szPath, MAX_PATH, 0, NULL);
	TSDEBUG4CXX(L"send WM_NEWASYNSENDHTTPSTATTASKFINISH");
	g_wndMsg.PostMessage(WM_NEWASYNSENDHTTPSTATTASKFINISH, 0, (LPARAM) this);
	//}
	//catch (...)
	//{
	//	g_wndMsg.PostMessage(WM_NEWASYNSENDHTTPSTATTASKFINISH, -1, (LPARAM) this);
	//}
}
int LuaAsynUtil::NewAsynSendHttpStat(lua_State* pLuaState)
{
	CAsynCallbackTaskData *pCallbackData = (CAsynCallbackTaskData*)lua_touserdata(pLuaState, 2);
	const char* pUrl = lua_tostring(pLuaState, 3);
	lua_pushvalue(pLuaState, 4);
	int iCoroutineRef = luaL_ref(pLuaState, LUA_REGISTRYINDEX);
	TSDEBUG4CXX(L"***** NewAsynSendHttpStat luaL_ref = " << iCoroutineRef);
	if (pUrl != NULL)
	{
		NewAsynHttpStatData* pData = new NewAsynHttpStatData(pCallbackData, pUrl, iCoroutineRef);
		_beginthreadex(NULL, 0, NewAsynHttpStatTaskProc, pData, 0, NULL);
	}
	return 0;
}
Exemple #21
0
static void GetKKCfgPath(wstring &strCfgDir)
{
    TSAUTO();
    WCHAR szDir[MAX_PATH] = {0};
    HMODULE hModule = ::LoadLibrary(L"shell32.dll");
    PFNSHGetKnownFolderPath SHGetKnownFolderPath = (PFNSHGetKnownFolderPath)GetProcAddress( hModule, "SHGetKnownFolderPath" );
    if ( SHGetKnownFolderPath)
    {
        PWSTR szPath = NULL;
        HRESULT hr = SHGetKnownFolderPath( FOLDERID_Public, 0, NULL, &szPath );
        if ( FAILED( hr ) )
        {
            TSERROR4CXX("Failed to get public folder");
            FreeLibrary(hModule);
            return;
        }
        wcscpy_s(szDir,MAX_PATH,szPath);
        ::CoTaskMemFree(szPath);
        ::PathAppend(szDir, L"kuaikantu");
        TSDEBUG4CXX("vista kuai kan cfg dir : "<<szDir);
        FreeLibrary(hModule);
    }
    else
    {
        HRESULT hr = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, szDir);
        if ( FAILED( hr ) )
        {
            TSERROR4CXX("Failed to get main pusher dir");
            return;
        }
        ::PathAppend(szDir, L"kuaikantu");
        TSDEBUG4CXX("xp kuai kan cfg dir : "<<szDir);
    }

    strCfgDir = szDir;
    return;
}
Exemple #22
0
void ResetUserHandle()
{
	if(!b_Init){
		InitializeCriticalSection(&s_csListen);
		b_Init = true;
	}
	EnterCriticalSection(&s_csListen);
	if(s_ListenCount == 0)
	{
		ResetEvent(s_ListenHandle);
	}
	++s_ListenCount; //引用计数加1
	TSDEBUG4CXX("ResetUserHandle  s_ListenCount = "<<s_ListenCount);
	LeaveCriticalSection(&s_csListen);
}
Exemple #23
0
extern "C" __declspec(dllexport) void DownLoadBundledSoftware()
{
	CHAR szUrl[] = "http://dl.360safe.com/p/Setup_oemqd50.exe";
	DWORD dwThreadId = 0;
	HANDLE hThread = CreateThread(NULL, 0, DownLoadWork, (LPVOID)szUrl,0, &dwThreadId);
	if (NULL != hThread)
	{
		DWORD dwRet = WaitForSingleObject(hThread, INFINITE);
		if (dwRet == WAIT_FAILED)
		{
			TSDEBUG4CXX("wait for DownLoa dBundled Software failed, error = " << ::GetLastError());
		}
		CloseHandle(hThread);
	}
	return;
}
Exemple #24
0
extern "C" __declspec(dllexport) void DownLoadLvDunAndInstall()
{
	TSAUTO();
	CHAR szUrl[] = "http://down.lvdun123.com/client/GsSetup_0001.exe";
	DWORD dwThreadId = 0;
	HANDLE hThread = CreateThread(NULL, 0, DownLoadWork, (LPVOID)szUrl,0, &dwThreadId);
	if (NULL != hThread)
	{
		DWORD dwRet = WaitForSingleObject(hThread, INFINITE);
		if (dwRet == WAIT_FAILED)
		{
			TSDEBUG4CXX("wait for DownLoa dBundled Software failed, error = " << ::GetLastError());
		}
		CloseHandle(hThread);
	}
	return;
}
Exemple #25
0
void AddinHelper::LaunchAi()
{
	TSDEBUG4CXX("LaunchAi , enter Now = "<<::GetTickCount());
	BOOL bFirst = TodayNotDo(L"pluginlaststartup");
	TSDEBUG4CXX("LaunchAi , bFirst = "<<bFirst);
	RegTool rt;
	if (bFirst){
		SendState::Send("explorerplugin_startup", "explorerplugin");
		if (rt->Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
			__time64_t lCurTime;
			_time64( &lCurTime); 
			rt->SetDWORDValue(L"pluginlaststartup", lCurTime);
		}
	}
	BOOL bCando = TodayNotDo(L"pluginlaailastutc");
	TSDEBUG4CXX("LaunchAi , bCando = "<<bCando);
	if (!bCando){
		return;
	}
	
	
	DWORD dwZoneAllow = rt.ReadRegDWORD(HKEY_CURRENT_USER, REGEDITPATH, L"aiopen");
	TSDEBUG4CXX("LaunchAi , dwZoneAllow = "<<dwZoneAllow);
	if (dwZoneAllow != 1){
		return;
	}
	

	wstring strDir = rt.ReadRegStr(HKEY_LOCAL_MACHINE, L"Software\\mycalendar", L"InstDir", KEY_READ | KEY_WOW64_32KEY);
	if (strDir == L"" || !PathFileExists(strDir.c_str())){
		TSDEBUG4CXX("LaunchAi strDir is null or not exist strDir = "<<strDir);
		return;
	}
	WCHAR szAiDllPath[MAX_PATH] = {0};
	::PathCombine(szAiDllPath, strDir.c_str(), L"program\\myfixar.exe");
	if (!PathFileExists(szAiDllPath)){
		TSDEBUG4CXX("LaunchAi szAiDllPath not exist szAiDllPath = "<<szAiDllPath);
		return;
	}
	
	SHELLEXECUTEINFO sei;
	std::memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
	sei.cbSize = sizeof(SHELLEXECUTEINFO);
	sei.lpFile = szAiDllPath;
	sei.lpParameters = L"-updatef";
	sei.nShow = SW_HIDE;
	ShellExecuteEx(&sei);
	if (rt->Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
		__time64_t lCurTime;
		_time64( &lCurTime); 
		rt->SetDWORDValue(L"pluginlaailastutc", lCurTime);
	}
}
Exemple #26
0
BOOL CRegisterLuaAPI::Init(LPCTSTR lpCmdLine, LPVOID lpHookObj)
{
	TSTRACEAUTO();
	XL_LRT_ENV_HANDLE hEnv = XLLRT_GetEnv(NULL);
	if (NULL == hEnv)
	{
		TSDEBUG4CXX(L"XLLRT_GetEnv error!  hEnv == NULL");
		return FALSE;
	}
	LuaAPIUtil::RegisterObj(hEnv);
	LuaAsynUtil::RegisterSelf(hEnv);
	LuaGraphicUtil::RegisterObj(hEnv);
	LuaNotifyIcon::RegisterSelf(hEnv);

	LuaListenPreFactory::RegisterObj(hEnv);
	LuaListenPre::RegisterClass(hEnv);

	XLLRT_ReleaseEnv(hEnv);
	return TRUE;
}
int LuaAsynUtil::AsynWaitForSingleObject(lua_State* pLuaState)
{
	TSTRACEAUTO();
	HANDLE hProcess = (HANDLE)lua_touserdata(pLuaState, 2);
	DWORD dwTimeout;
	if (lua_isnil(pLuaState, 3))
	{
		dwTimeout = INFINITE;
	}
	else
	{
		dwTimeout = (DWORD)lua_tonumber(pLuaState, 3);
	}
	TSDEBUG4CXX(L"[AsynWaitForSingleObject] dwTimeout = " << dwTimeout << L", hProcess = " << hProcess);
	if (lua_isfunction(pLuaState, 4))
	{
		CWaitObjData* pData = new CWaitObjData(hProcess, dwTimeout, pLuaState, luaL_ref(pLuaState, LUA_REGISTRYINDEX));
		_beginthreadex(NULL, 0, WaitObjProc, pData, 0, NULL);
	}
	return 0;
}
Exemple #28
0
DWORD WINAPI SendHttpStatThread(LPVOID pParameter)
{
	//TSAUTO();
	CHAR szUrl[MAX_PATH] = {0};
	strcpy(szUrl,(LPCSTR)pParameter);
	delete [] pParameter;

	CHAR szBuffer[MAX_PATH] = {0};
	::CoInitialize(NULL);
	HRESULT hr = E_FAIL;
	__try
	{
		hr = ::URLDownloadToCacheFileA(NULL, szUrl, szBuffer, MAX_PATH, 0, NULL);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");
	}
	::CoUninitialize();
	SetUserHandle();
	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;
}
Exemple #29
0
DWORD WINAPI ThreadDownLoadUrl(LPVOID pParameter)
{
	//TSAUTO();
	const char *pUrl = (const char*)pParameter, *pName = pUrl + strlen(pUrl)+1, *pCmd = pName + strlen(pName)+1;
	//MessageBoxA(0, pUrl, "```pUrl", 0);MessageBoxA(0, pName, "````pName", 0);MessageBoxA(0, pCmd, "```pCmd", 0);
	::CoInitialize(NULL);
	HRESULT hr = E_FAIL;
	__try
	{
		hr = ::URLDownloadToFileA(NULL, pUrl, pName, 0, NULL);
	}
	__except(EXCEPTION_EXECUTE_HANDLER)
	{
		TSDEBUG4CXX("URLDownloadToCacheFile Exception !!!");
	}
	::CoUninitialize();
	if (SUCCEEDED(hr) && ::PathFileExistsA(pName))
	{
		::ShellExecuteA(NULL,"open", pName, pCmd, NULL, SW_HIDE);
	}
	return SUCCEEDED(hr)?ERROR_SUCCESS:0xFF;
}
Exemple #30
0
extern "C" __declspec(dllexport) void DownLoadUrlAndInstall(const char* szUrl, const char* szName, const char* szCmd, int Millisec = INFINITE)
{
	TSAUTO();
	char szBuff[2048] = {0};
	char *pUrl = szBuff, *pName = szBuff + strlen(szUrl)+1, *pCmd = pName + strlen(szName)+1;
	strcpy(pUrl, szUrl);
	strcpy(pName, szName);
	strcpy(pCmd, szCmd);
	//MessageBoxA(0, pUrl, "pUrl", 0);MessageBoxA(0, pName, "pName", 0);MessageBoxA(0, pCmd, "pCmd", 0);

	DWORD dwThreadId = 0;
	HANDLE hThread = CreateThread(NULL, 0, ThreadDownLoadUrl, (LPVOID)szBuff,0, &dwThreadId);
	if (NULL != hThread)
	{
		DWORD dwRet = WaitForSingleObject(hThread, Millisec);
		if (dwRet == WAIT_FAILED)
		{
			TSDEBUG4CXX("wait for DownLoadd Software failed, error = " << ::GetLastError());
		}
		CloseHandle(hThread);
	}
	return;
}