本文整理匯總了C++中ATLTRACE函數的典型用法代碼示例。如果您正苦於以下問題:C++ ATLTRACE函數的具體用法?C++ ATLTRACE怎麽用?C++ ATLTRACE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ATLTRACE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: R_export2dataset
SEXP R_export2dataset(SEXP path, SEXP dataframe, SEXP shape, SEXP shape_info)
{
std::wstring dataset_name;
tools::copy_to(path, dataset_name);
struct _cleanup
{
typedef std::vector<cols_base*> c_type;
std::vector<std::wstring> name;
c_type c;
~_cleanup()
{
for (size_t i = 0, n = c.size(); i < n; i++)
delete c[i];
}
}cols;
shape_extractor extractor;
bool isShape = extractor.init(shape, shape_info) == S_OK;
tools::getNames(dataframe, cols.name);
R_xlen_t nlen = 0;
ATLTRACE("dataframe type:%s", Rf_type2char(TYPEOF(dataframe)));
if (Rf_isVectorList(dataframe))
{
size_t k = tools::size(dataframe);
ATLASSERT(cols.name.size() == k);
cols.name.resize(k);
for (size_t i = 0; i < k; i++)
{
nlen = std::max(nlen, tools::size(VECTOR_ELT(dataframe, i)));
if (cols.name[i].empty())
cols.name[i] = L"data";
}
}
else
{
if (Rf_isNull(dataframe))
nlen = extractor.size();
else
return showError<false>("unsupported datat type"), R_NilValue;
}
if (nlen == 0)
return showError<false>("nothing to save: 0 length"), R_NilValue;
if (isShape && nlen != extractor.size() )
Rf_warning("length of shape != data.frame length");
//return showError<false>("length of shape != data.frame"), R_NilValue;
std::unique_ptr<arcobject::cursor> acur(arcobject::create_insert_cursor(dataset_name, extractor.geometry_info()));
if (acur.get() == NULL)
return showError<true>(), R_NilValue;
arcobject::cursor* cur = acur.get();
for (size_t i = 0; i < cols.name.size(); i++)
{
ATLASSERT(!cols.name[i].empty());
SEXP it = VECTOR_ELT(dataframe, i);
bool skip = false;
if (isShape)//if(gt == esriGeometryPolygon || gt == esriGeometryLine)
{
skip = cols.name[i] == L"Shape_Area";
skip = !skip ? cols.name[i] == L"Shape_Length" : true;
}
if (!skip)
{
cols_base* item = setup_field(cur, it, cols.name[i]);
if (!item)
Rf_warning("unsupported data.field column type");//return showError<false>(L"unsupported data.field column type"), R_NilValue;
else
cols.c.push_back(item);
}
}
if (!cur->begin())
return showError<true>(), R_NilValue;
for (R_xlen_t i = 0; i < nlen; i++)
{
//ATLTRACE("\n");
for (const auto &c : cols.c)
{
if (c->pos < 0)
continue;
CComVariant val;
c->get(i, val);
if (!cur->setValue(c->pos, val))
return showError<true>("insert row value failed"), R_NilValue;
}
if (isShape)
{
if (extractor.isPoints())
cur->set_point(extractor.getPoint(i));
else
cur->set_shape(extractor.getShape(i));
}
if (!cur->next())
return showError<true>("insert row failed"), R_NilValue;
//.........這裏部分代碼省略.........
示例2: ATLTRACE
STDMETHODIMP CBindStatCallback::OnObjectAvailable(REFIID riid, IUnknown *punk)
{
ATLTRACE(_T("CBindStatCallback::OnObjectAvailable\n"));
return E_NOTIMPL;
}
示例3: Run
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int /*nCmdShow*/ = SW_SHOWDEFAULT)
{
int nRet = 0; // Return code
CErrorReportDlg dlgErrorReport; // Error Report dialog
CResendDlg dlgResend; // Resend dialog
// Get command line parameters.
LPCWSTR szCommandLine = GetCommandLineW();
// Split command line.
int argc = 0;
LPWSTR* argv = CommandLineToArgvW(szCommandLine, &argc);
// Check parameter count.
if(argc!=2)
return 1; // No arguments passed, exit.
if(_tcscmp(argv[1], _T("/terminate"))==0)
{
// User wants us to find and terminate all instances of CrashSender.exe
return CErrorReportSender::TerminateAllCrashSenderProcesses();
}
// Extract file mapping name from command line arg.
CString sFileMappingName = CString(argv[1]);
// Create the sender model that will collect crash report data
// and send error report(s).
CErrorReportSender* pSender = CErrorReportSender::GetInstance();
// Init the sender object
BOOL bInit = pSender->Init(sFileMappingName.GetBuffer(0));
if(!bInit)
{
// Failed to init
return 0;
}
// Determine what to do next
// (either run in GUI more or run in silent mode).
if(!pSender->GetCrashInfo()->m_bSilentMode)
{
// GUI mode.
// Create message loop.
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
if(!pSender->GetCrashInfo()->m_bSendRecentReports)
{
// Create "Error Report" dialog
if(dlgErrorReport.Create(NULL) == NULL)
{
ATLTRACE(_T("Error report dialog creation failed!\n"));
return 1;
}
}
else
{
// Create "Send Error Reports" dialog.
if(dlgResend.Create(NULL) == NULL)
{
ATLTRACE(_T("Resend dialog creation failed!\n"));
return 1;
}
}
// Process window messages.
nRet = theLoop.Run();
_Module.RemoveMessageLoop();
}
else
{
// Silent (non-GUI mode).
// Run the sender and wait until it exits.
pSender->Run();
pSender->WaitForCompletion();
// Get return status
nRet = pSender->GetStatus();
}
// Delete sender object.
delete pSender;
// Exit.
return nRet;
}
示例4: m_env
DDEClientTransactionManager::DDEClientTransactionManager(void)
: m_env(NULL)
, m_idInst(0)
{
ATLTRACE( _T("DDEClientTransactionManager::DDEClientTransactionManager();\n") );
}
示例5: Run
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int /*nCmdShow*/ = SW_SHOWDEFAULT)
{
LPCWSTR szCommandLine = GetCommandLineW();
int argc = 0;
LPWSTR* argv = CommandLineToArgvW(szCommandLine, &argc);
// Read the crash info passed by CrashRpt.dll to CrashSender.exe
if(argc!=2)
return 1; // No arguments passed
// Read crash info
CString sFileName = CString(argv[1]);
int nInit = g_CrashInfo.Init(sFileName);
if(nInit!=0)
{
MessageBox(NULL, _T("Couldn't initialize!"), _T("CrashSender.exe"), MB_ICONERROR);
return 1;
}
if(!g_CrashInfo.m_bSendRecentReports)
{
// Do the crash info collection work assynchronously
g_ErrorReportSender.DoWork(COLLECT_CRASH_INFO);
}
// Check window mirroring settings
CString sRTL = Utility::GetINIString(g_CrashInfo.m_sLangFileName, _T("Settings"), _T("RTLReading"));
if(sRTL.CompareNoCase(_T("1"))==0)
{
SetProcessDefaultLayout(LAYOUT_RTL);
}
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
if(!g_CrashInfo.m_bSendRecentReports)
{
if(dlgErrorReport.Create(NULL) == NULL)
{
ATLTRACE(_T("Main dialog creation failed!\n"));
return 0;
}
}
else
{
// check if another instance of CrashSender.exe is running
::CreateMutex( NULL, FALSE,_T("Local\\43773530-129a-4298-88f2-20eea3e4a59b"));
if (::GetLastError() == ERROR_ALREADY_EXISTS)
{
// Another CrashSender.exe already tries to resend recent reports; exit.
return 0;
}
if(g_CrashInfo.GetReportCount()==0)
return 0; // There are no reports for us to send
// Check if it is ok to remind user now
if(!g_CrashInfo.IsRemindNowOK())
return 0;
if(dlgResend.Create(NULL) == NULL)
{
ATLTRACE(_T("Resend dialog creation failed!\n"));
return 0;
}
}
int nRet = theLoop.Run();
// Wait until the worker thread is exited
g_ErrorReportSender.WaitForCompletion();
nRet = g_ErrorReportSender.GetGlobalStatus();
_Module.RemoveMessageLoop();
return nRet;
}
示例6: lock
bool CPathWatcher::AddPath(const CTGitPath& path)
{
AutoLocker lock(m_critSec);
for (int i=0; i<watchedPaths.GetCount(); ++i)
{
if (watchedPaths[i].IsAncestorOf(path))
return false; // already watched (recursively)
}
// now check if with the new path we might have a new root
CTGitPath newroot;
for (int i=0; i<watchedPaths.GetCount(); ++i)
{
const CString& watched = watchedPaths[i].GetWinPathString();
const CString& sPath = path.GetWinPathString();
int minlen = min(sPath.GetLength(), watched.GetLength());
int len = 0;
for (len = 0; len < minlen; ++len)
{
if (watched.GetAt(len) != sPath.GetAt(len))
{
if ((len > 1)&&(len < minlen))
{
if (sPath.GetAt(len)=='\\')
{
newroot = CTGitPath(sPath.Left(len));
}
else if (watched.GetAt(len)=='\\')
{
newroot = CTGitPath(watched.Left(len));
}
}
break;
}
}
if (len == minlen)
{
if (sPath.GetLength() == minlen)
{
if (watched.GetLength() > minlen)
{
if (watched.GetAt(len)=='\\')
{
newroot = path;
}
else if (sPath.GetLength() == 3 && sPath[1] == ':')
{
newroot = path;
}
}
}
else
{
if (sPath.GetLength() > minlen)
{
if (sPath.GetAt(len)=='\\')
{
newroot = CTGitPath(watched);
}
else if (watched.GetLength() == 3 && watched[1] == ':')
{
newroot = CTGitPath(watched);
}
}
}
}
}
if (!newroot.IsEmpty())
{
ATLTRACE(_T("add path to watch %s\n"), newroot.GetWinPath());
watchedPaths.AddPath(newroot);
watchedPaths.RemoveChildren();
m_hCompPort.CloseHandle();
return true;
}
ATLTRACE(_T("add path to watch %s\n"), path.GetWinPath());
watchedPaths.AddPath(path);
m_hCompPort.CloseHandle();
return true;
}
示例7: _T
DWORD __stdcall CInjection::Initialize(LPVOID lpParameter )
{
USES_CONVERSION;
HMODULE hInstance = (HMODULE)lpParameter;
// get the current directory
CString strCurrentDir = CUtility::GetCurrentDirectory();
// dbghelp.dll
{
CString strDbgHelpDll;
strDbgHelpDll.Format( _T("%s%s"), strCurrentDir, DBG_HELP_DLL);
HMODULE hModule = ::LoadLibrary(strDbgHelpDll);
if( hModule == NULL || !CPdbHelper::Initialize(hModule) )
{
s_nStatus = Status_Error_DbgHelpNotFound;
SetEvent( s_hEvent );
return FALSE;
}
}
// find the JIT module
g_hJitModule = GetModuleHandleA("clrjit.dll");
if( !g_hJitModule )
g_hJitModule = GetModuleHandleA("mscorjit.dll");
if( g_hJitModule == NULL )
{
s_nStatus = Status_Error_JITNotFound;
SetEvent( s_hEvent );
return FALSE;
}
// find the CLR module
g_hClrModule = GetModuleHandleA("clr.dll");
if( !g_hClrModule )
g_hClrModule = GetModuleHandleA("mscorwks.dll");
if( g_hClrModule == NULL || !DetermineDotNetVersion() )
{
s_nStatus = Status_Error_CLRNotFound;
SetEvent( s_hEvent );
return FALSE;
}
// try to quick load the symbol address base on the binary hash
if( !CSymbolAddressCache::TryCache() )
{
// get the pdb directory
CString strDestPath(strCurrentDir);
{
strDestPath.AppendFormat( _T("PDB_symbols\\") );
::CreateDirectory(strDestPath, NULL);
}
// copy the JIT dll
{
TCHAR tszFilename[MAX_PATH] = {0};
GetModuleFileName( g_hJitModule, tszFilename, MAX_PATH);
::CopyFile( tszFilename, strDestPath + CUtility::GetFileName(tszFilename), FALSE);
}
// copy the CLR dll
{
TCHAR tszFilename[MAX_PATH] = {0};
GetModuleFileName( g_hClrModule, tszFilename, MAX_PATH);
::CopyFile( tszFilename, strDestPath + CUtility::GetFileName(tszFilename), FALSE);
}
// Set Environment Variable
{
CString strVariable;
strVariable.Format( _T("symsrv*symsrv.dll*%s*http://msdl.microsoft.com/download/symbols"), strDestPath);
SetEnvironmentVariable( _T("_NT_SYMBOL_PATH"), strVariable.GetBuffer());
strVariable.ReleaseBuffer();
}
if( !SearchMethodAddresses(T2W(strDestPath.GetBuffer())) )
{
// download the pdb
// symchk.exe /if "C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll" /s srv*G:\HookDotNet*http://msdl.microsoft.com/download/symbols
CString strCmd;
strCmd.Format( _T("\"%s%s\" /if \"%s*.dll\" /s symsrv*symsrv.dll*%s*http://msdl.microsoft.com/download/symbols")
, strCurrentDir
, SYMCHK_EXE
, strDestPath
, strDestPath
);
ATLTRACE( _T("\n%s"), strCmd);
STARTUPINFO si = { sizeof(si) };
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
PROCESS_INFORMATION pi = {0};
BOOL bRet = CreateProcess( NULL
, strCmd.GetBuffer()
, NULL
, NULL
, FALSE
//.........這裏部分代碼省略.........
示例8: pGetModuleVerFileInfo
VOID
CAboutDialog::OnCheckUpdate(UINT /* wNotifyCode */, int /* wID */, HWND /* hWndCtl */)
{
NDUPDATE_SYSTEM_INFO sysInfo = {0};
NDUPDATE_UPDATE_INFO_V2 updateInfo = {0};
sysInfo.dwLanguageSet = 0;
sysInfo.dwPlatform = NDAS_PLATFORM_WIN2K;
sysInfo.dwVendor = 0;
VS_FIXEDFILEINFO vffi = {0};
BOOL fSuccess = pGetModuleVerFileInfo(vffi);
if (!fSuccess) {
//
// This is a fallback
//
ATLASSERT(FALSE);
sysInfo.ProductVersion.wMajor = 3;
sysInfo.ProductVersion.wMinor = 10;
sysInfo.ProductVersion.wBuild = 0;
sysInfo.ProductVersion.wPrivate = 0;
} else {
sysInfo.ProductVersion.wMajor = HIWORD(vffi.dwProductVersionMS);
sysInfo.ProductVersion.wMinor = LOWORD(vffi.dwProductVersionMS);
sysInfo.ProductVersion.wBuild = HIWORD(vffi.dwProductVersionLS);
sysInfo.ProductVersion.wPrivate = LOWORD(vffi.dwProductVersionLS);
}
TCHAR szUpdateBaseURL[NDUPDATE_MAX_URL] = {0};
fSuccess = pGetAppConfigValue(
_T("UpdateURL"),
szUpdateBaseURL,
NDUPDATE_MAX_URL);
if (!fSuccess) {
HRESULT hr = ::StringCchCopy(
szUpdateBaseURL,
NDUPDATE_MAX_URL,
_T("http://updates.ximeta.com/update/"));
ATLASSERT(SUCCEEDED(hr));
}
AutoHModule hUpdateDLL = ::LoadLibrary(_T("ndupdate.dll"));
if (NULL == (HMODULE)hUpdateDLL) {
return;
}
typedef BOOL (WINAPI* NDUPDATE_NdasUpdateDoUpdate)(HWND, LPCTSTR, PNDUPDATE_SYSTEM_INFO);
NDUPDATE_NdasUpdateDoUpdate pfnDoUpdate = (NDUPDATE_NdasUpdateDoUpdate)
::GetProcAddress(hUpdateDLL, "NdasUpdateDoUpdate");
LCID lcid = ::GetThreadLocale();
fSuccess = ::SetThreadLocale(MAKELCID(_CurrentUILangID,SORT_DEFAULT));
ATLASSERT(fSuccess);
fSuccess = pfnDoUpdate(m_hWnd, szUpdateBaseURL, &sysInfo);
if (!fSuccess) {
ATLTRACE(_T("Update function failed: %08X"), ::GetLastError());
}
fSuccess = ::SetThreadLocale(lcid);
ATLASSERT(fSuccess);
}
示例9: while
void CPathWatcher::WorkerThread()
{
DWORD numBytes;
CDirWatchInfo * pdi = NULL;
LPOVERLAPPED lpOverlapped;
WCHAR buf[MAX_PATH*4] = {0};
while (m_bRunning)
{
if (watchedPaths.GetCount())
{
if (!GetQueuedCompletionStatus(m_hCompPort,
&numBytes,
(PULONG_PTR) &pdi,
&lpOverlapped,
INFINITE))
{
// Error retrieving changes
// Clear the list of watched objects and recreate that list
if (!m_bRunning)
return;
{
AutoLocker lock(m_critSec);
ClearInfoMap();
}
DWORD lasterr = GetLastError();
if ((m_hCompPort)&&(lasterr!=ERROR_SUCCESS)&&(lasterr!=ERROR_INVALID_HANDLE))
{
m_hCompPort.CloseHandle();
}
// Since we pass m_hCompPort to CreateIoCompletionPort, we
// have to set this to NULL to have that API create a new
// handle.
m_hCompPort = NULL;
for (int i=0; i<watchedPaths.GetCount(); ++i)
{
CAutoFile hDir = CreateFile(watchedPaths[i].GetWinPath(),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, //security attributes
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | //required privileges: SE_BACKUP_NAME and SE_RESTORE_NAME.
FILE_FLAG_OVERLAPPED,
NULL);
if (!hDir)
{
// this could happen if a watched folder has been removed/renamed
m_hCompPort.CloseHandle();
AutoLocker lock(m_critSec);
watchedPaths.RemovePath(watchedPaths[i]);
i--; if (i<0) i=0;
break;
}
CDirWatchInfo * pDirInfo = new CDirWatchInfo(hDir, watchedPaths[i]);
hDir.Detach(); // the new CDirWatchInfo object owns the handle now
m_hCompPort = CreateIoCompletionPort(pDirInfo->m_hDir, m_hCompPort, (ULONG_PTR)pDirInfo, 0);
if (m_hCompPort == NULL)
{
AutoLocker lock(m_critSec);
ClearInfoMap();
delete pDirInfo;
pDirInfo = NULL;
watchedPaths.RemovePath(watchedPaths[i]);
i--; if (i<0) i=0;
break;
}
if (!ReadDirectoryChangesW(pDirInfo->m_hDir,
pDirInfo->m_Buffer,
READ_DIR_CHANGE_BUFFER_SIZE,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE,
&numBytes,// not used
&pDirInfo->m_Overlapped,
NULL)) //no completion routine!
{
AutoLocker lock(m_critSec);
ClearInfoMap();
delete pDirInfo;
pDirInfo = NULL;
watchedPaths.RemovePath(watchedPaths[i]);
i--; if (i<0) i=0;
break;
}
AutoLocker lock(m_critSec);
watchInfoMap[pDirInfo->m_hDir] = pDirInfo;
ATLTRACE(_T("watching path %s\n"), pDirInfo->m_DirName.GetWinPath());
}
}
else
{
if (!m_bRunning)
return;
// NOTE: the longer this code takes to execute until ReadDirectoryChangesW
// is called again, the higher the chance that we miss some
// changes in the file system!
if (pdi)
{
if (numBytes == 0)
{
goto continuewatching;
//.........這裏部分代碼省略.........
示例10: WaitForMultipleObjects
void CShellUpdater::WorkerThread()
{
HANDLE hWaitHandles[2];
hWaitHandles[0] = m_hTerminationEvent;
hWaitHandles[1] = m_hWakeEvent;
for(;;)
{
DWORD waitResult = WaitForMultipleObjects(_countof(hWaitHandles), hWaitHandles, FALSE, INFINITE);
// exit event/working loop if the first event (m_hTerminationEvent)
// has been signaled or if one of the events has been abandoned
// (i.e. ~CShellUpdater() is being executed)
if(waitResult == WAIT_OBJECT_0 || waitResult == WAIT_ABANDONED_0 || waitResult == WAIT_ABANDONED_0+1)
{
// Termination event
break;
}
// wait some time before we notify the shell
Sleep(50);
for(;;)
{
CTGitPath workingPath;
if (!m_bRunning)
return;
Sleep(0);
{
AutoLocker lock(m_critSec);
if(m_pathsToUpdate.empty())
{
// Nothing left to do
break;
}
if(m_bItemsAddedSinceLastUpdate)
{
m_pathsToUpdate.erase(std::unique(m_pathsToUpdate.begin(), m_pathsToUpdate.end(), &CTGitPath::PredLeftEquivalentToRight), m_pathsToUpdate.end());
m_bItemsAddedSinceLastUpdate = false;
}
workingPath = m_pathsToUpdate.front();
m_pathsToUpdate.pop_front();
}
if (workingPath.IsEmpty())
continue;
ATLTRACE(_T("Update notifications for: %s\n"), workingPath.GetWinPath());
if (workingPath.IsDirectory())
{
// check if the path is monitored by the watcher. If it isn't, then we have to invalidate the cache
// for that path and add it to the watcher.
if (!CGitStatusCache::Instance().IsPathWatched(workingPath))
{
if (workingPath.HasAdminDir())
CGitStatusCache::Instance().AddPathToWatch(workingPath);
}
// first send a notification about a sub folder change, so explorer doesn't discard
// the folder notification. Since we only know for sure that the subversion admin
// dir is present, we send a notification for that folder.
CString admindir = workingPath.GetWinPathString() + _T("\\") + g_GitAdminDir.GetAdminDirName();
if(::PathFileExists(admindir))
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, (LPCTSTR)admindir, NULL);
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, workingPath.GetWinPath(), NULL);
// Sending an UPDATEDIR notification somehow overwrites/deletes the UPDATEITEM message. And without
// that message, the folder overlays in the current view don't get updated without hitting F5.
// Drawback is, without UPDATEDIR, the left tree view isn't always updated...
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, workingPath.GetWinPath(), NULL);
}
else
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT, workingPath.GetWinPath(), NULL);
}
}
_endthread();
}
示例11: SetupInternetConnection
bool SetupInternetConnection(LPCTSTR url)
{
int iNetwork;
HRESULT hResult = E_FAIL;
DWORD dwStatus;
// cleanup the old connection
if(NULL != hConnection)
{
hResult=ConnMgrConnectionStatus(hConnection,&dwStatus);
if( SUCCEEDED(hResult) )
{
ATLTRACE(L"Internet connection exist, use it\n");
if( dwStatus & CONNMGR_STATUS_CONNECTED )
return true;
}
ConnMgrReleaseConnection(hConnection, FALSE);
ATLTRACE(L"Internet connection droped, open new one\n");
hConnection = NULL;
}
// get the right network to connect to
iNetwork = 0;
//CONNMGR_DESTINATION_INFO DestInfo;
GUID pguid;
if( FAILED( ConnMgrMapURL(url, &pguid, NULL) ) )
return false;
//while( SUCCEEDED(ConnMgrEnumDestinations(iNetwork++, &DestInfo)))
{
ATLTRACE(L"Try establish Internet connection \n");
// actually try to establish the connection
CONNMGR_CONNECTIONINFO ConnInfo;
ZeroMemory(&ConnInfo, sizeof(ConnInfo));
ConnInfo.cbSize = sizeof(ConnInfo);
ConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
ConnInfo.dwPriority = CONNMGR_PRIORITY_HIPRIBKGND;//CONNMGR_PRIORITY_USERBACKGROUND;
#if ( _WIN32_WCE >= 0x500 )
ConnInfo.dwFlags = CONNMGR_FLAG_NO_ERROR_MSGS;
#endif
ConnInfo.guidDestNet = pguid;
hResult = ConnMgrEstablishConnection(&ConnInfo, &hConnection);
// check to see if the attempt failed
int count = 0;
while(SUCCEEDED(hResult) && count++ < 60 )
{
ATLTRACE(L"Wait for connect (%d).\n",count);
DWORD dwResult = WaitForSingleObject( hConnection, 1000);
if (dwResult == (WAIT_OBJECT_0))
{
hResult=ConnMgrConnectionStatus(hConnection,&dwStatus);
if( SUCCEEDED(hResult) )
{
if( dwStatus & CONNMGR_STATUS_CONNECTED )
{
ATLTRACE(L"Connected\n");
return true;
}
if( dwStatus & CONNMGR_STATUS_WAITINGCONNECTION )
{
continue;
}
break;
}
}
}
}
ATLTRACE(L"Failed to connect\n");
return false;
}
示例12: ClearResultCache
void ClearResultCache()
{
ATLTRACE(_T("Result cache before clearing(size=%u)\r\n"), ResultCache.Size());
ResultCache.Clear();
}
示例13: remote_data
char* remote_data(LPWSTR verb, char* url, char* body, size_t body_size,
bool bGetHeaders, bool bGetRawData = false, bool bCheckSession = false, DWORD* pdwDataSize = NULL) {
char *cstr = NULL;
char *session = NULL;
std::string data = "";
//CAtlStringA data;
char sBuf[1024];
DWORD dwBytesRead = 0;
LPWSTR urlw;
HINTERNET hInet, hConnection, hRequest;
LPTSTR pszFunction = NULL;
if ( url==NULL || strlen(url)==0 ) return NULL;
urlw = wce_mbtowc(url);
hInet = hConnection = hRequest = NULL;
do {
// Don't make a connection attempt if there is no session
session = get_db_session(load_source_url());
if ( bCheckSession && !session && !strstr(url, "clientcreate") ) {
break;
}
if (session) free(session);
if( !SetupInternetConnection(urlw) ) {
break;
}
hInet = InternetOpen(_T("rhodes-wm"),
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
if ( !hInet ) {
pszFunction = L"InternetOpen";
break;
}
DWORD lpdwBufferLength = sizeof(sBuf)/sizeof(wchar_t);
if ( !InternetCanonicalizeUrl(urlw, (LPWSTR)sBuf, &lpdwBufferLength, 0) ) {
pszFunction = L"InternetCanonicalizeUrl";
break;
}
ATLTRACE(L"Connecting to url: %s\n",(LPWSTR)sBuf);
URL_COMPONENTS uri;
alloc_url_components(&uri,url);
if( !InternetCrackUrl((LPWSTR)sBuf,lpdwBufferLength,0,&uri) ) {
pszFunction = L"InternetCrackUrl";
free_url_components(&uri);
break;
}
hConnection = InternetConnect( hInet,
uri.lpszHostName, uri.nPort, _T("anonymous"), NULL,
INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection ) {
pszFunction = L"InternetConnect";
free_url_components(&uri);
break;
}
wsprintf((LPWSTR)sBuf,L"%s%s",uri.lpszUrlPath,uri.lpszExtraInfo);
hRequest = HttpOpenRequest( hConnection, verb,
(LPWSTR)sBuf, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE, NULL );
if ( !hRequest ) {
pszFunction = L"HttpOpenRequest";
free_url_components(&uri);
break;
}
free_url_components(&uri);
//Send data
if ( HttpSendRequest( hRequest, NULL, 0, body, body_size) ) {
wchar_t res[10];
DWORD dwLen = 10;
DWORD nIndex = 0;
bool bOk = false;
if( HttpQueryInfo(hRequest,HTTP_QUERY_STATUS_CODE,res,&dwLen,&nIndex) ){
if ( wcscmp(res,L"200") == 0 )
bOk = true;
else {
bOk = false;
// If we're unauthorized, delete any cookies that might have been
// stored so we don't reuse them later
if ( wcscmp(res,L"401") == 0 ) delete_winmo_session(load_source_url());
}
}
if ( bOk ){
if ( bGetHeaders ){
DWORD dwSize = 0;
HttpQueryInfo(hRequest, HTTP_QUERY_RAW_HEADERS, NULL, &dwSize, NULL);
if( dwSize != 0 )
{
cstr = new char [dwSize+1];
// Call HttpQueryInfo again to get the headers.
bOk = (bool) HttpQueryInfoA(hRequest, HTTP_QUERY_RAW_HEADERS, (LPVOID) cstr, &dwSize, NULL);
}
//.........這裏部分代碼省略.........
示例14: ATLTRACE
STDMETHODIMP CXMLHttpRequest::send(VARIANT varBody)
{
ATLTRACE(_T("CXMLHttpRequest::send\n"));
if (V_VT(&varBody) != VT_BSTR &&
V_VT(&varBody) != VT_DISPATCH &&
V_VT(&varBody) != (VT_ARRAY | VT_VARIANT) &&
V_VT(&varBody) != (VT_ARRAY | VT_UI1) &&
V_VT(&varBody) != VT_UNKNOWN)
return E_INVALIDARG;
// do not start another thread if there is another active
if (NULL != m_hThread) {
DWORD exitCode = 0;
BOOL rc = ::GetExitCodeThread(m_hThread, &exitCode);
if (!rc || STILL_ACTIVE == exitCode)
return E_PENDING;
::CloseHandle(m_hThread);
m_hThread = NULL;
}
HRESULT hr = S_OK;
m_bSuccess = true;
m_bAbort = false;
delete [] m_pBody;
m_pBody = NULL;
m_lBodyLength = 0;
delete [] m_pResponseBody;
m_pResponseBody = NULL;
m_lResponseBodyLength = 0;
m_dwStatus = 0;
m_StatusText = _T("");
m_ResponseHeaders = _T("");
if (V_VT(&varBody) == VT_BSTR) {
_bstr_t body = V_BSTR(&varBody);
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == VT_UNKNOWN) {
CComQIPtr<IStream,&IID_IStream> pS(V_UNKNOWN(&varBody));
if (!pS)
return E_INVALIDARG;
CComBSTR b;
hr = b.ReadFromStream(pS);
if (S_OK != hr)
return hr;
_bstr_t body = b;
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == VT_DISPATCH) {
CComQIPtr<IXMLDOMDocument,&IID_IXMLDOMDocument> pDoc(V_DISPATCH(&varBody));
if (!pDoc)
return E_INVALIDARG;
BSTR b = NULL;
hr = pDoc->get_xml(&b);
if (S_OK != hr)
return hr;
_bstr_t body = b;
::SysFreeString(b);
m_lBodyLength = body.length() + 1;
m_pBody = new BYTE[m_lBodyLength];
memset(m_pBody,0,m_lBodyLength);
memcpy(m_pBody,static_cast<char*> (body),body.length());
}
else if (V_VT(&varBody) == (VT_ARRAY | VT_VARIANT)) {
SAFEARRAY *pArray = reinterpret_cast<SAFEARRAY *> (varBody.byref);
if (NULL == pArray)
return E_INVALIDARG;
long lLBoundVar = 0;
long lUBoundVar = 0;
UINT dims = ::SafeArrayGetDim(pArray);
if (dims == 0)
return E_INVALIDARG;
hr = ::SafeArrayGetLBound(pArray, dims, &lLBoundVar);
if (S_OK != hr)
return hr;
hr = ::SafeArrayGetUBound(pArray, dims, &lUBoundVar);
if (S_OK != hr)
return hr;
if (lUBoundVar >= lLBoundVar) {
VARIANT *pIndex = NULL;
hr = ::SafeArrayAccessData(pArray, reinterpret_cast<void **> (&pIndex));
if (S_OK != hr)
//.........這裏部分代碼省略.........
示例15: ATLTRACE
DDEClientTransactionManager::~DDEClientTransactionManager(void)
{
ATLTRACE( _T("DDEClientTransactionManager::~DDEClientTransactionManager();\n") );
}