Пример #1
0
//初始化函数
BOOL CLogonServerApp::InitInstance()
{
	__super::InitInstance();

	//初始化组件
	AfxInitRichEdit2();
	InitCommonControls();
	AfxEnableControlContainer();

	HMODULE hMod;
	hMod = LoadLibrary(TEXT( "riched20.dll"));

	//设置注册表
	SetRegistryKey(szSystemRegKey);

	//获取目录
	GetModuleFileName(AfxGetInstanceHandle(),m_szDirWork,sizeof(m_szDirWork));
	int nModuleLen=lstrlen(m_szDirWork);
	int nProcessLen=lstrlen(m_pszExeName)+lstrlen(TEXT(".EXE"));
	m_szDirWork[nModuleLen-nProcessLen]=0;

	//创建目录
	lstrcat(m_szDirWork, TEXT("CustomFace"));
	CreateDirectory(m_szDirWork, NULL) ;

	//显示主窗口
	CLogonServerDlg ServerDlg;
	m_pMainWnd=&ServerDlg;
	ServerDlg.DoModal();

	FreeLibrary(hMod);

	return FALSE;
}
Пример #2
0
LRESULT CLXWebSiteApp::OnFileMountWorkgroupSite(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CLogonServerDlg dlg;
	dlg.m_server = L"213.115.5.45";
	dlg.m_username = L"Sigurd";
	dlg.m_password = L"testing";

	if (dlg.DoModal() == IDOK)
	{
#if 0
		COAUTHIDENTITY cauthid;
		cauthid.User = dlg.m_username;
		cauthid.UserLength = dlg.m_username.length();
		cauthid.Domain = L"WORKGROUP";
		cauthid.DomainLength = wcslen(cauthid.Domain);
		cauthid.Password = dlg.m_password;
		cauthid.PasswordLength = dlg.m_password.length();
		cauthid.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;

		COAUTHINFO cauthi;
		cauthi.dwAuthnSvc = RPC_C_AUTHN_WINNT;
		cauthi.dwAuthzSvc = RPC_C_AUTHZ_NONE;
		cauthi.pwszServerPrincName = NULL;
		cauthi.dwAuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
		cauthi.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
		cauthi.pAuthIdentityData = &cauthid;
		cauthi.dwCapabilities = EOAC_NONE;

		COSERVERINFO csi;
		csi.dwReserved1 = 0;
		csi.pwszName = dlg.m_server;
		csi.pAuthInfo = &cauthi;
		csi.dwReserved2 = 0;

		MULTI_QI qi[2];
		qi[0].pIID = &XMILLWEBLib::IID_IXmillWorkgroup;
		qi[0].pItf = NULL;
		qi[0].hr = 0;

		qi[1].pIID = &XMILLWEBLib::IID_ILFileSystem;
		qi[1].pItf = NULL;
		qi[1].hr = 0;

		HRESULT hr = CoCreateInstanceEx(XMILLWEBLib::CLSID_XmillWorkgroup, NULL, CLSCTX_SERVER/*CLSCTX_ALL*/, &csi, 2, qi);

		if (SUCCEEDED(qi[0].hr) && SUCCEEDED(qi[1].hr))
		{
			//XMILLWEBLib::IXmillWorkgroupPtr workgroup;//(L"XMillWeb.WebSite");

			//CComQIPtr<IClientSecurity> csec = qi[0].pItf;

			hr = CoSetProxyBlanket(qi[0].pItf, 
				cauthi.dwAuthnSvc,
				cauthi.dwAuthzSvc,
				cauthi.pwszServerPrincName,
				cauthi.dwAuthnLevel,
				cauthi.dwImpersonationLevel,
				cauthi.pAuthIdentityData,
				cauthi.dwCapabilities);

			hr = CoSetProxyBlanket(qi[1].pItf, 
				cauthi.dwAuthnSvc,
				cauthi.dwAuthzSvc,
				cauthi.pwszServerPrincName,
				cauthi.dwAuthnLevel,
				cauthi.dwImpersonationLevel,
				cauthi.pAuthIdentityData,
				cauthi.dwCapabilities);

			//workgroup = qi.pItf;
			//qi.pItf->Release();

			CComObject<CWorkgroupDocument>* pWorkgroupDocument;
			CComObject<CWorkgroupDocument>::CreateInstance(&pWorkgroupDocument);
			if (pWorkgroupDocument)
			{
				pWorkgroupDocument->AddRef();

				pWorkgroupDocument->m_workgroup = qi[0].pItf;
				pWorkgroupDocument->m_filesystem = qi[1].pItf;

				pWorkgroupDocument->ShowView();
			}

			/*
			try
			{
				_bstr_t result = webSite->TestMethod("Test");
			}
			catch (_com_error &e)
			{
				ComError(e);
			}
			*/
		}
		else
		{
			MessageBox(hWnd, "Couldn't connect to Server", "", MB_OK);
		}
#endif
	}

	return 0;
}