示例#1
0
CIniFile::CIniFile()
	: m_strPath()
{
	tchar szPath[MAX_PATH+1] = { 0 };

	// Get the Applications full path and name.
	DWORD dwChars = ::GetModuleFileName(NULL, szPath, MAX_PATH);

	if (dwChars == 0)
		throw WCL::Win32Exception(::GetLastError(), TXT("Failed to retrieve the full path of the module"));

	// Assume no path by default.
	tchar* pszFileName = szPath;

	// Find the start of the filename.
	tchar* pszFinalSep = tstrrchr(szPath, TXT('\\'));

	if (pszFinalSep != nullptr)
		pszFileName = pszFinalSep+1;

	// Append or replace the extension.
	tchar* pszExt = tstrrchr(pszFileName, TXT('.'));

	if (pszExt != nullptr)
		tstrcpy(pszExt, TXT(".ini"));
	else
		tstrcat(pszFileName, TXT(".ini"));

	// Save final path.
	m_strPath = szPath;
}
示例#2
0
inline CValue::CValue(const CString& sValue)
	: m_eType(MDST_STRING)
	, m_bNull(false)
	, m_sValue(new tchar[tstrlen(sValue)+1])
{
	tstrcpy(m_sValue, sValue);
}
示例#3
0
文件: util.c 项目: ChloeTigre/wimlib
static void
wimlib_vmsg(const tchar *tag, const tchar *format,
	    va_list va, bool perror)
{
#if !defined(ENABLE_DEBUG)
	if (wimlib_print_errors)
#endif
	{
		int errno_save = errno;
		fflush(stdout);
		tfputs(tag, wimlib_error_file);
		tvfprintf(wimlib_error_file, format, va);
		if (perror && errno_save != 0) {
			tchar buf[64];
			int res;
			res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
			if (res) {
				tsprintf(buf,
					 T("unknown error (errno=%d)"),
					 errno_save);
			}
		#ifdef WIN32
			if (errno_save == EBUSY)
				tstrcpy(buf, T("Resource busy"));
		#endif
			tfprintf(wimlib_error_file, T(": %"TS), buf);
		}
		tputc(T('\n'), wimlib_error_file);
		fflush(wimlib_error_file);
		errno = errno_save;
	}
}
示例#4
0
std::wstring CServerPath::GetSafePath() const
{
	if (empty()) {
		return std::wstring();
	}

	#define INTLENGTH 20 // 2^64 - 1

	int len = 5 // Type and 2x' ' and terminating 0
		+ INTLENGTH; // Max length of prefix

	len += m_data->m_prefix ? m_data->m_prefix->size() : 0;
	for (auto const& segment : m_data->m_segments) {
		len += segment.size() + 2 + INTLENGTH;
	}

	std::wstring safepath;
	safepath.resize(len);
	wchar_t * const start = &safepath[0];
	wchar_t * t = &safepath[0];

	t = fast_sprint_number(t, m_type);
	*(t++) = ' ';
	t = fast_sprint_number(t, m_data->m_prefix ? m_data->m_prefix->size() : 0);

	if (m_data->m_prefix) {
		*(t++) = ' ';
		tstrcpy(t, m_data->m_prefix->c_str());
		t += m_data->m_prefix->size();
	}

	for (auto const& segment : m_data->m_segments) {
		*(t++) = ' ';
		t = fast_sprint_number(t, segment.size());
		*(t++) = ' ';
		tstrcpy(t, segment.c_str());
		t += segment.size();
	}
	safepath.resize(t - start);
	safepath.shrink_to_fit();

	return safepath;
}
示例#5
0
wxString CServerPath::GetSafePath() const
{
	if (empty())
		return wxString();

	#define INTLENGTH 20 // 2^64 - 1

	int len = 5 // Type and 2x' ' and terminating 0
		+ INTLENGTH; // Max length of prefix

	len += m_data->m_prefix ? m_data->m_prefix->size() : 0;
	for( auto const& segment : m_data->m_segments ) {
		len += segment.size() + 2 + INTLENGTH;
	}

	wxString safepath;
	{
		wxStringBuffer start(safepath, len);
		wxChar* t = start;

		t = fast_sprint_number(t, m_type);
		*(t++) = ' ';
		t = fast_sprint_number(t, m_data->m_prefix ? m_data->m_prefix->size() : 0);

		if (m_data->m_prefix) {
			*(t++) = ' ';
			tstrcpy(t, m_data->m_prefix->c_str());
			t += m_data->m_prefix->size();
		}

		for( auto const& segment : m_data->m_segments ) {
			*(t++) = ' ';
			t = fast_sprint_number(t, segment.size());
			*(t++) = ' ';
			tstrcpy(t, segment.c_str());
			t += segment.size();
		}
		*t = 0;
	}
	safepath.Shrink();

	return safepath;
}
示例#6
0
inline CValue::CValue(const CValue& oValue)
	: m_eType(oValue.m_eType)
	, m_bNull(oValue.m_bNull)
{
	if (m_eType != MDST_STRING)
	{
		memcpy(m_uValue, oValue.m_uValue, sizeof(m_uValue));
	}
	else
	{
		m_sValue = new tchar[tstrlen(oValue.m_sValue)+1];
		tstrcpy(m_sValue, oValue.m_sValue);
	}
}
示例#7
0
inline const CValue& CValue::operator=(const CValue& oValue)
{
	m_eType = oValue.m_eType;
	m_bNull = oValue.m_bNull;

	if (m_eType != MDST_STRING)
	{
		memcpy(m_uValue, oValue.m_uValue, sizeof(m_uValue));
	}
	else
	{
		m_sValue = new tchar[tstrlen(oValue.m_sValue)+1];
		tstrcpy(m_sValue, oValue.m_sValue);
	}

	return *this;
}
示例#8
0
BOOL CSystemInfo::GetCameraInfo()
{
	::CoInitialize(NULL);

	ICreateDevEnum *pSysDevEnum = NULL;
	BOOL            bIsGetSuccess = FALSE;
	HRESULT         hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
	if (hr == S_FALSE)	return FALSE;	

	IEnumMoniker *pEnumCat = NULL;
	hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
	if (hr == S_FALSE)	return FALSE;	

	//Enumerate   the   monikers.   
	IMoniker *pMoniker = NULL;
	ULONG   cFetched;
	while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
	{
		IPropertyBag *pPropBag = NULL;
		hr = pMoniker->BindToStorage(0,   0,   IID_IPropertyBag, (void **)&pPropBag);
		if (SUCCEEDED(hr))
		{
			//To retrieve the filter's  friendly   name,   do   the   following:   
			VARIANT   varName;
			VariantInit(&varName);
			hr = pPropBag->Read(L"FriendlyName", &varName, 0);
			if (SUCCEEDED(hr))
			{
				_bstr_t str(varName);
				tstrcpy(m_stCltHardInfo.szWebcam, MAX_PATH, (TCHAR*)str);
				bIsGetSuccess = TRUE;
			}
			VariantClear(&varName);

			//Remember   to   release   pFilter   later.
			pPropBag->Release();
		}
		pMoniker->Release();
		if (bIsGetSuccess) break;
	}
	pEnumCat->Release();
	pSysDevEnum->Release();
	::CoUninitialize();
	return TRUE;
}
void Window::Init()
{
	window = 0;

	//strcpy_s(m_WinClassName, "ssWindowClass");
	tstrcpy(m_WinClassName, _T("ssWindowClass"));
	// AD_TODO: there are other ways of implementing callbacks other than static 
	// functions, in the future i'd like to check them out.

	// Keep track of this object in a static list by inserting in the list a reference to this object.
	// This is a key part of the c++ callback handler implementation. By tracking the Object or 
	// specifically the hWnd property of Object, the generic callback handler can determine whether
	// this object is being requested by a callback operation.
	{
		if (m_WindowList == NULL)
			m_WindowList = new std::list<Window*>;
		m_WindowList->push_back(this); 
	}
}
示例#10
0
STI8Version& CSystemInfo::GetI8Version()
{
	stdex::tString strPath;
	strPath = GetRootDir();

	tstrcpy(m_stI8Version.szCltSvrVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\i8deskclisvr.exe")).c_str());
	tstrcpy(m_stI8Version.szCltUIVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\Baronline.exe")).c_str());
#ifdef _DEBUG
    tstrcpy(m_stI8Version.szCltDataVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\I8ClientDataCoreD.dll")).c_str());
#else
    tstrcpy(m_stI8Version.szCltDataVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\I8ClientDataCore.dll")).c_str());
#endif

	strPath = GetSystemDir();
    tstrcpy(m_stI8Version.szProtVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\drivers\\wxProt.sys")).c_str());
    tstrcpy(m_stI8Version.szVirtualDiskVer, MAX_PATH, GetFileVersion(strPath + TEXT("\\drivers\\wxNda.sys")).c_str());

	return m_stI8Version;
}
示例#11
0
STSysCfgInfo& CSystemInfo::GetSysCfgInfo(SOCKET hSocket)
{
	GetComputerName();
	GetOptSystem();

	//首先取得连接上服务器的socket的本机ip
	stdex::tString     strIP;
	sockaddr_in addr = {0};
	int         nSize = sizeof(addr);

	if (SOCKET_ERROR == getsockname(hSocket, (PSOCKADDR)&addr, &nSize))
		return m_stSysCfgInfo;
	strIP = (LPCTSTR)_bstr_t(inet_ntoa(addr.sin_addr));


	IP_ADAPTER_INFO  Adapter[10] = {0};
	PIP_ADAPTER_INFO pAdapter = Adapter;

	nSize = sizeof(Adapter);
	if (ERROR_SUCCESS != GetAdaptersInfo(Adapter, (PULONG)&nSize))
		pAdapter = NULL;
	while (strIP.size() && pAdapter != NULL)
	{
		_IP_ADDR_STRING* pIpAddress = &pAdapter->IpAddressList;
		while (pIpAddress != NULL)
		{
			if (std::string(CT2A(strIP.c_str())) == pIpAddress->IpAddress.String)
				goto do_next;
			pIpAddress = pIpAddress->Next;
		}
		pAdapter = pAdapter->Next;
	}

do_next:
	if (pAdapter != NULL)
	{
		tstrcpy(m_stCltHardInfo.szNIC, MAX_PATH, CA2T(pAdapter->Description));
		m_stSysCfgInfo.dwIP = inet_addr(CT2A(strIP.c_str()));
		m_stSysCfgInfo.dwGate = inet_addr(pAdapter->GatewayList.IpAddress.String);
		m_stSysCfgInfo.dwSubMask = inet_addr(pAdapter->IpAddressList.IpMask.String);
		tsprintf(m_stSysCfgInfo.szMacAddr, MAX_PATH, TEXT("%02X-%02X-%02X-%02X-%02X-%02X"), 
			pAdapter->Address[0],
			pAdapter->Address[1],
			pAdapter->Address[2],
			pAdapter->Address[3],
			pAdapter->Address[4],
			pAdapter->Address[5]);
		IP_PER_ADAPTER_INFO perAdapter[10] = {0};
		nSize = sizeof(perAdapter);
		if (ERROR_SUCCESS == GetPerAdapterInfo(pAdapter->Index, perAdapter, (PULONG)&nSize))
		{
			m_stSysCfgInfo.dwDns0 = inet_addr(perAdapter->DnsServerList.IpAddress.String);
			if (perAdapter->DnsServerList.Next != NULL)
			{
				m_stSysCfgInfo.dwDns1 = inet_addr(perAdapter->DnsServerList.Next->IpAddress.String);
			}
		}
	}

	return m_stSysCfgInfo;
}
示例#12
0
文件: split.c 项目: twwbond/wimlib
static int
write_split_wim(WIMStruct *orig_wim, const tchar *swm_name,
		struct swm_info *swm_info, int write_flags)
{
	size_t swm_name_len;
	tchar *swm_name_buf;
	const tchar *dot;
	tchar *swm_suffix;
	size_t swm_base_name_len;

	union wimlib_progress_info progress;
	unsigned part_number;
	int ret;
	u8 guid[GUID_SIZE];

	swm_name_len = tstrlen(swm_name);
	swm_name_buf = alloca((swm_name_len + 20) * sizeof(tchar));
	tstrcpy(swm_name_buf, swm_name);
	dot = tstrchr(swm_name_buf, T('.'));
	if (dot) {
		swm_base_name_len = dot - swm_name_buf;
		swm_suffix = alloca((tstrlen(dot) + 1) * sizeof(tchar));
		tstrcpy(swm_suffix, dot);
	} else {
		swm_base_name_len = swm_name_len;
		swm_suffix = alloca(1 * sizeof(tchar));
		swm_suffix[0] = T('\0');
	}

	progress.split.completed_bytes = 0;
	progress.split.total_bytes = 0;
	for (part_number = 1; part_number <= swm_info->num_parts; part_number++)
		progress.split.total_bytes += swm_info->parts[part_number - 1].size;
	progress.split.total_parts = swm_info->num_parts;

	generate_guid(guid);

	for (part_number = 1; part_number <= swm_info->num_parts; part_number++) {
		int part_write_flags;
		wimlib_progress_func_t progfunc;

		if (part_number != 1) {
			tsprintf(swm_name_buf + swm_base_name_len,
				 T("%u%"TS), part_number, swm_suffix);
		}

		progress.split.cur_part_number = part_number;
		progress.split.part_name = swm_name_buf;

		ret = call_progress(orig_wim->progfunc,
				    WIMLIB_PROGRESS_MSG_SPLIT_BEGIN_PART,
				    &progress,
				    orig_wim->progctx);
		if (ret)
			return ret;

		part_write_flags = write_flags;
		part_write_flags |= WIMLIB_WRITE_FLAG_USE_EXISTING_TOTALBYTES;
		if (part_number != 1)
			part_write_flags |= WIMLIB_WRITE_FLAG_NO_METADATA;

		progfunc = orig_wim->progfunc;
		orig_wim->progfunc = NULL;
		ret = write_wim_part(orig_wim,
				     progress.split.part_name,
				     WIMLIB_ALL_IMAGES,
				     part_write_flags,
				     1,
				     part_number,
				     swm_info->num_parts,
				     &swm_info->parts[part_number - 1].blob_list,
				     guid);
		orig_wim->progfunc = progfunc;
		if (ret)
			return ret;

		progress.split.completed_bytes += swm_info->parts[part_number - 1].size;

		ret = call_progress(orig_wim->progfunc,
				    WIMLIB_PROGRESS_MSG_SPLIT_END_PART,
				    &progress,
				    orig_wim->progctx);
		if (ret)
			return ret;
	}
	return 0;
}
void Window::SetWndClassName(const tstring& name)
{
	tstrcpy(m_WinClassName, name.c_str());
}