📄 adofiltr.cpp
字号:
/////////////////////////////////////////////////////////////////////////////
//
// AdoFiltr.cpp : Wrapper functions for the DESKTOPTODEVICE and
// DEVICETODESKTOP functions exported by ADOFILTR.DLL.
//
// Original code from:
// Copyright (c) 2000-2001 Nathan Lewis
// nlewis@programmer.net
// http://www.ticz.com/~nlewis
//
// Modified by Olivier G. Gaumond (2002)
// ogaumond@yahoo.com
//
// I encapsulated the functions in a C++ class
//
//
// This program is free software; you can redistribute it and/or modify it
// so long as credit is given to the original author listed above.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AdoFiltr.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAdoFiltr* CAdoFiltr::s_pSelf = NULL;
CAdoFiltr::CAdoFiltr()
{
m_hLib = LoadAdoFiltrDll();
if (!m_hLib)
m_hrLoadErr = HRESULT_FROM_WIN32(GetLastError());
}
CAdoFiltr::~CAdoFiltr()
{
// Unload the DLL
if (m_hLib)
FreeLibrary(m_hLib);
}
CAdoFiltr* CAdoFiltr::getInstance()
{
if (CAdoFiltr::s_pSelf == NULL)
s_pSelf = new CAdoFiltr();
return s_pSelf;
}
//////////////////////////////////////////////////////////////////////
// Methods
//////////////////////////////////////////////////////////////////////
HRESULT CAdoFiltr::DesktopToDevice(LPCTSTR pszDesktopLocn,
LPCTSTR pszTableList,
BOOL bSync/* = FALSE*/,
BOOL bOverwrite/* = TRUE*/,
LPCTSTR pszDeviceLocn/* = NULL*/)
{
return CallAdoFiltrFunc("DESKTOPTODEVICE", pszDesktopLocn, pszTableList,
bSync, bOverwrite, pszDeviceLocn);
}
HRESULT CAdoFiltr::DeviceToDesktop(LPCTSTR pszDesktopLocn,
LPCTSTR pszTableList,
BOOL bSync/* = FALSE*/,
BOOL bOverwrite/* = TRUE*/,
LPCTSTR pszDeviceLocn/* = NULL*/)
{
return CallAdoFiltrFunc("DEVICETODESKTOP", pszDesktopLocn, pszTableList,
bSync, bOverwrite, pszDeviceLocn);
}
HMODULE CAdoFiltr::LoadAdoFiltrDll()
{
HKEY hKey=NULL;
HMODULE hLib=NULL;
TCHAR szPath[MAX_PATH]={0};
LONG lPath=sizeof(szPath);
// Get path where CE Services / ActiveSync was installed from registry
if(ERROR_SUCCESS==RegOpenKeyEx(HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\CEAPPMGR.EXE"),
0, KEY_READ, &hKey))
{
if(ERROR_SUCCESS==RegQueryValue(hKey, NULL, szPath, &lPath))
{
// Replace the filename (CEAPPMGR.EXE) with DLL filename
LPTSTR pFile=_tcsrchr(szPath, L'\\');
if(pFile)
{
lstrcpy(_tcsinc(pFile), _T("adofiltr.dll"));
// Now load the DLL
hLib=LoadLibrary(szPath);
}
}
RegCloseKey(hKey);
}
return hLib;
}
HRESULT CAdoFiltr::CallAdoFiltrFunc(LPCSTR pszFuncName, LPCTSTR pszDesktopLocn,
LPCTSTR pszTableList, BOOL bSync, BOOL bOverwrite,
LPCTSTR pszDeviceLocn)
{
// Start by loading the DLL
HRESULT hResult=NO_ERROR;
if(m_hLib != NULL)
{
// Get the address of the specified function within the DLL
typedef HRESULT (WINAPI* pfnDTD)(LPCTSTR,LPCTSTR,BOOL,int,LPCTSTR);
pfnDTD pfn=(pfnDTD)GetProcAddress(m_hLib, pszFuncName);
if(NULL==pfn)
hResult=HRESULT_FROM_WIN32(GetLastError());
else
{
// Call the function
hResult=pfn(pszDesktopLocn, pszTableList, bSync, bOverwrite,
pszDeviceLocn);
}
}
else
{
hResult = m_hrLoadErr;
}
return hResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -