Beispiel #1
0
/**
 * リソースの検索
 * @param[in] lpszName リソース ID
 * @param[in] lpszType リソースの型へのポインタ
 * @return インスタンス
 */
HINSTANCE CWndProc::FindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType)
{
	HINSTANCE hInst = GetResourceHandle();
	if ((hInst != GetInstanceHandle()) && (::FindResource(hInst, lpszName, lpszType) != NULL))
	{
		return hInst;
	}
	return GetInstanceHandle();
}
Beispiel #2
0
int Window::SetWindowIcon( int smalliconnum, int bigiconnum )
{
	if ( wd.wcx.hIcon == NULL )
	{
		wd.wcx.hIcon = LoadIcon( NULL, MAKEINTRESOURCE( bigiconnum ) );
		wd.wcx.hIconSm = LoadIcon( NULL, MAKEINTRESOURCE( smalliconnum ) );
	} else
	{
		wd.wcx.hIcon = LoadIcon( GetInstanceHandle(), MAKEINTRESOURCE( bigiconnum ) );
		wd.wcx.hIconSm = LoadIcon( GetInstanceHandle(), MAKEINTRESOURCE( smalliconnum ) );
		SendMessage( GetWindowHandle(), WM_SETICON, ICON_BIG, (WPARAM)( wd.wcx.hIcon ) );
		SendMessage( GetWindowHandle(), WM_SETICON, ICON_SMALL, (WPARAM)( wd.wcx.hIconSm ) );
	}
	return 0;
}
Beispiel #3
0
int Window::SetWindowIcon( char *smalliconname, char *bigiconname )
{
	if ( wd.wcx.hIcon == NULL )
	{
		wd.wcx.hIcon = LoadIcon( NULL, bigiconname );
		wd.wcx.hIconSm = LoadIcon( NULL, smalliconname );
	} else
	{
		wd.wcx.hIcon = LoadIcon( GetInstanceHandle(), bigiconname );
		wd.wcx.hIconSm = LoadIcon( GetInstanceHandle(), smalliconname );
		SendMessage( GetWindowHandle(), WM_SETICON, ICON_BIG, (WPARAM)( wd.wcx.hIcon ) );
		SendMessage( GetWindowHandle(), WM_SETICON, ICON_SMALL, (WPARAM)( wd.wcx.hIconSm ) );
	}
	return 0;
}
Beispiel #4
0
/**
 * 初期化
 */
void CTraceWnd::Initialize()
{
	WNDCLASS wc;
	ZeroMemory(&wc, sizeof(wc));
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = ::DefWindowProc;
	wc.hInstance = GetInstanceHandle();
	wc.hCursor = ::LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = static_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH));
	wc.lpszClassName = s_szClassName;
	if (!::RegisterClass(&wc))
	{
		return;
	}

#if 1
	m_nFlags = 4;
#else
	m_nFlags = 1;
	m_tfh = textfile_create(OEMTEXT("traceout.txt"), 0x800);
#endif

	tracecfg.posx = CW_USEDEFAULT;
	tracecfg.posy = CW_USEDEFAULT;
	tracecfg.width = CW_USEDEFAULT;
	tracecfg.height = CW_USEDEFAULT;
	ini_read(file_getcd(np2trace), inititle, initbl, NELEMENTS(initbl));

	if (!CreateEx(WS_EX_CONTROLPARENT, s_szClassName, s_szTitle, WS_OVERLAPPEDWINDOW, tracecfg.posx, tracecfg.posy, tracecfg.width, tracecfg.height, NULL, NULL))
	{
		return;
	}
	ShowWindow(SW_SHOW);
	UpdateWindow();
}
BOOL CTabCtrl::Create(DWORD dwStyle,const RECT* rect,HWND hParentWnd,UINT nID)
{
	m_hWnd=CreateWindowEx(0L,WC_TABCONTROL,szEmpty,dwStyle,
		rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,
		hParentWnd,(HMENU)(ULONG_PTR)nID,GetInstanceHandle(),NULL);
	if (m_hWnd==NULL)
		return FALSE;
	return TRUE;
}
Beispiel #6
0
/* virtual */BOOL CTargetWnd::CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,
		LPCTSTR lpszWindowName, DWORD dwStyle,
		int x, int y, int nWidth, int nHeight,
		HWND hWndParent, HMENU nIDorHMenu, LPVOID lpParam)
{
	return (m_hWnd=CreateWindowEx(dwExStyle,lpszClassName,
		lpszWindowName,dwStyle,x,y,nWidth,nHeight,
		hWndParent,nIDorHMenu,GetInstanceHandle(),lpParam))!=NULL;
}
BOOL CToolBarCtrl::Create(DWORD dwStyle,const RECT* rect,HWND hWndParent,UINT nID)
{
	m_hWnd=CreateWindowEx(0L,TOOLBARCLASSNAME,szEmpty,
      dwStyle,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,
      hWndParent,(HMENU)(ULONG_PTR)nID,GetInstanceHandle(),NULL);
	if (m_hWnd==NULL)
		return FALSE;
	::SendMessage(m_hWnd,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
	return TRUE;
}
Beispiel #8
0
std::wstring DialogPackage::SelectFolder(HWND parent, const std::wstring& existingPath)
{
	LPCWSTR dialog = MAKEINTRESOURCE(IDD_PACKAGESELECTFOLDER_DIALOG);
	std::wstring folder = existingPath;
	if (DialogBoxParam(GetInstanceHandle(), dialog, parent, SelectFolderDlgProc, (LPARAM)&folder) != 1)
	{
		folder.clear();
	}
	return folder;
}
Beispiel #9
0
void CDateTimeCtrlEx::CreateControls()
{
	RECT rcClientRect;
	GetClientRect(&rcClientRect);
	DWORD dwStyle=WS_GROUP | WS_TABSTOP | WS_CHILD;
	if (GetStyle()&WS_DISABLED)
		dwStyle|=WS_DISABLED;

	if (m_hTheme!=NULL && m_pDrawThemeBackground!=NULL)
		rcClientRect.right-=BUTTON_WIDTHTHEME;
	else
		rcClientRect.right-=BUTTON_WIDTHORIG;

	if (m_hTimePickerWnd==NULL)
	{
		m_hTimePickerWnd=CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE,
			"SysDateTimePick32","",dwStyle|DTS_RIGHTALIGN|WS_VISIBLE,
			rcClientRect.left,rcClientRect.top,rcClientRect.right,rcClientRect.bottom,
			*this,(HMENU)IDC_EXPLICITIDATE,GetInstanceHandle(),NULL);
	}
	if (m_hEditWnd==NULL)
	{
		m_hEditWnd=CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE|WS_EX_RIGHT,
			"EDIT","",dwStyle|ES_AUTOHSCROLL|ES_NUMBER,
			rcClientRect.left,rcClientRect.top,rcClientRect.right,rcClientRect.bottom,
			*this,(HMENU)IDC_RELATIVEDATE,GetInstanceHandle(),NULL);
	}
	if (m_hSpinWnd==NULL)
	{
		m_hSpinWnd=CreateWindowEx(WS_EX_NOPARENTNOTIFY|WS_EX_CLIENTEDGE|WS_EX_RIGHT,
			"msctls_updown32","",dwStyle|UDS_ALIGNRIGHT|UDS_ARROWKEYS,
			rcClientRect.left,rcClientRect.top,rcClientRect.right,rcClientRect.bottom,
			*this,(HMENU)IDC_RELATIVEDATESPIN,GetInstanceHandle(),NULL);
		::SendMessage(m_hSpinWnd,UDM_SETBUDDY,WPARAM(m_hEditWnd),0);
		::SendMessage(m_hSpinWnd,UDM_SETRANGE,0,UD_MAXVAL);
	}

	
	SetRelativeDate(0,DTXF_NOMODECHANGE);

	m_dwFlags&=~DontSendNotifications;
}
BOOL CComboBoxEx::Create(DWORD dwStyle, const RECT* rect, HWND hParentWnd, UINT nID)
{
	CCommonCtrl::m_hWnd=CreateWindowEx(0L,WC_COMBOBOXEX,szEmpty,dwStyle,
		rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,
		hParentWnd,(HMENU)(ULONG_PTR)nID,GetInstanceHandle(),NULL);
	if (CCommonCtrl::m_hWnd==NULL)
		return FALSE;
	CComboBox::m_hWnd=(HWND)::SendMessage(CCommonCtrl::m_hWnd,CBEM_GETCOMBOCONTROL,0,0);
	CEdit::m_hWnd=(HWND)::SendMessage(CCommonCtrl::m_hWnd,CBEM_GETEDITCONTROL,0,0);
	return TRUE;
}
Beispiel #11
0
std::pair<std::wstring, std::wstring> DialogPackage::SelectPlugin(HWND parent)
{
	LPCWSTR dialog = MAKEINTRESOURCE(IDD_PACKAGESELECTPLUGIN_DIALOG);
	std::pair<std::wstring, std::wstring> plugins;
	if (DialogBoxParam(GetInstanceHandle(), dialog, parent, SelectPluginDlgProc, (LPARAM)&plugins) != 1)
	{
		plugins.first.clear();
		plugins.second.clear();
	}
	return plugins;
}
Beispiel #12
0
/*!
@brief ウィンドウの生成
@par   関数説明
ウィンドウを生成する。
決まったウィンドウサイズやスタイルがあるのであればあらかじめSet系関数で設定しておく。
@param nCmdShow WinMain関数で取得できる第三引数。
@return 0=成功。
@return 1=生成に失敗。
*/
unsigned long Window::MakeWindow( int nCmdShow )
{
	//int w = 0, h = 0;
	unsigned long err;

	if ( wd.WindowParent )
	{
		SetWindowStyleDirect( GetWindowStyle() | WS_CHILD );
	} else
	{
		SetWindowStyleDirect( GetWindowStyle() & ( ~WS_CHILD ) );
	}

	// 判定。
	//if ( GetPositionX() < 0 ){ SetPositionX( 0 ); w = GetWindowWidth();  SetWindowWidth( 640 );  }
	//if ( GetPositionY() < 0 ){ SetPositionY( 0 ); h = GetWindowHeight(); SetWindowHeight( 480 ); }

	//ウィンドウの生成
	wd.WindowHandle = CreateWindowEx(
		GetWindowStyleEx(),
		wd.wcx.lpszClassName,//MIKANCLASSNAME,//GetClassNameEx(),
		GetWindowName(),
		GetWindowStyle(),
		GetPositionX(), GetPositionY(),
		GetWindowWidth(), GetWindowHeight(),
		GetParentWindowHandle(),
		GetMenuHandle(),
		GetInstanceHandle(),
		GetParameter()
		);
	/*if ( w > 0 || h > 0 )
	{
	SetWindowSize( w, h );
	SetWindow();
	}*/

	//生成に失敗したら1を返して終了
	if ( wd.WindowHandle == NULL )
	{
		err = GetLastError();
		return err;
	}

	ShowWindow( wd.WindowHandle, nCmdShow );
	UpdateWindow( wd.WindowHandle );
	//  SetWindowText( wd.WindowParent, GetWindowName() );

	return 0;
}
Beispiel #13
0
BOOL CMDIChildWnd::Create(LPCTSTR lpszClassName,LPCTSTR lpszWindowName,DWORD dwStyle,const RECT* rect,CMDIFrameWnd* pParentWnd)
{
	if (pParentWnd==NULL)
		pParentWnd=(CMDIFrameWnd*)GetApp()->GetMainWnd();
	m_pParent=pParentWnd;
	MDICREATESTRUCT mcs;
	mcs.szClass=lpszClassName;
	mcs.szTitle=lpszWindowName;
	mcs.hOwner=GetInstanceHandle();
	if (rect!=NULL)
	{
		mcs.x=rect->left;
		mcs.y=rect->top;
		mcs.cx=rect->right-rect->left;
		mcs.cy=rect->bottom-rect->top;
	}
	else
	{
		mcs.x=CW_USEDEFAULT;
		mcs.y=CW_USEDEFAULT;
		mcs.cx=CW_USEDEFAULT;
		mcs.cy=CW_USEDEFAULT;
	}
	mcs.style=dwStyle&~(WS_MAXIMIZE|WS_VISIBLE);
	mcs.lParam=(LPARAM)this;

	HWND m_hWnd=(HWND)::SendMessage(pParentWnd->m_hWndMDIClient,WM_MDICREATE,0,(LPARAM)&mcs);
	
	if (m_hWnd==NULL)
		return FALSE;

	if (dwStyle&WS_VISIBLE)
	{
		::BringWindowToTop(m_hWnd);

		if (dwStyle&WS_MINIMIZE)
			ShowWindow(swShowMinimized);
		else if (dwStyle&WS_MAXIMIZE)
			ShowWindow(swShowMaximized);
		else
			ShowWindow(swShowNormal);

		pParentWnd->MDIActivate(m_hWnd);
		::SendMessage(pParentWnd->m_hWndMDIClient,WM_MDIREFRESHMENU,0,0);
	}
	return TRUE;
}
Beispiel #14
0
//  Return name of module.
DWORD CComDll::GetModuleFileName(char *pOutName, size_t stOutSize, BOOL bFullPath)
{
    DWORD dwRetval = 0;

    dwRetval = ::GetModuleFileName(GetInstanceHandle(), pOutName, stOutSize);
    if(dwRetval && FALSE == bFullPath)  {
        //  Don't return the full path, split it up to the filename only.
        char aName[_MAX_FNAME];
        char aExt[_MAX_EXT];
        _splitpath(pOutName, NULL, NULL, aName, aExt);
        strcpy(pOutName, aName);
        strcat(pOutName, aExt);
        dwRetval = strlen(pOutName);
    }

    return(dwRetval);
}
Beispiel #15
0
BOOL CFrameWnd::Create(LPCTSTR lpszClassName,LPCTSTR lpszWindowName,DWORD dwStyle,
				const RECT* rect,HWND hParentWnd,LPCTSTR lpszMenuName,DWORD dwExStyle)
{
	int x,y,nWidth,nHeight;
	if (rect==NULL)
	{
		if (!(dwStyle&WS_OVERLAPPED))
		{
			x=CW_USEDEFAULT;
			y=CW_USEDEFAULT;
			nWidth=CW_USEDEFAULT;
			nHeight=CW_USEDEFAULT;
		}
		else
		{
			x=0;
			y=0;
			nWidth=0;
			nHeight=0;
		}
	}
	else
	{
		x=rect->left;
		y=rect->top;
		nWidth=rect->right-rect->left;
		nHeight=rect->bottom-rect->top;
	}
	if(lpszMenuName!=NULL)
		m_hMenu=LoadMenu(lpszMenuName);
	
	m_hWnd=CreateWindowEx(dwExStyle,lpszClassName,lpszWindowName,dwStyle,
		x,y,nWidth,nHeight,hParentWnd,m_hMenu,GetInstanceHandle(),(void*)this);
	if (m_hWnd==NULL)
		return FALSE;
	if (dwExStyle&WS_VISIBLE)
		::ShowWindow(m_hWnd,SW_SHOWDEFAULT);
	::UpdateWindow(m_hWnd);
	return TRUE;
}
Beispiel #16
0
BOOL RegisterDataTimeExCltr()
{
	WNDCLASSEX wc;
	ZeroMemory(&wc,sizeof(WNDCLASSEX));
	wc.cbSize=sizeof(WNDCLASSEX);
	wc.style=CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW|CS_PARENTDC;
	wc.hInstance=GetInstanceHandle();
	wc.lpszClassName="DATETIMEPICKEX";
	wc.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1);
	wc.lpfnWndProc=CDateTimeCtrlEx::WndProc;
	if (RegisterClassEx(&wc)==NULL)
		return FALSE;

	ZeroMemory(&wc,sizeof(WNDCLASSEX));
	wc.cbSize=sizeof(WNDCLASSEX);
	wc.style=CS_DBLCLKS|CS_VREDRAW|CS_HREDRAW|CS_PARENTDC;
	wc.hInstance=GetResourceHandle(LanguageSpecificResource);
	wc.lpszClassName="DATETIMEPICKEX";
	wc.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1);
	wc.lpfnWndProc=CDateTimeCtrlEx::WndProc;
	return RegisterClassEx(&wc)!=NULL;
}
Beispiel #17
0
BOOL CMDIFrameWnd::CreateClient(LPCREATESTRUCT lpCreateStruct,HMENU hWindowMenu)
{
	DWORD dwStyle=WS_VISIBLE|WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|MDIS_ALLCHILDSTYLES;
	DWORD dwExStyle=WS_EX_CLIENTEDGE;
	
	CLIENTCREATESTRUCT ccs;
	ccs.hWindowMenu=hWindowMenu;
	ccs.idFirstChild=IDM_FIRST_MDICHILD;

	if (lpCreateStruct->style&(WS_HSCROLL|WS_VSCROLL))
	{
		dwStyle|=(lpCreateStruct->style&(WS_HSCROLL|WS_VSCROLL));
		ModifyStyle(WS_HSCROLL|WS_VSCROLL,0,SWP_NOREDRAW|SWP_FRAMECHANGED);
	}

	if ((m_hWndMDIClient=::CreateWindowEx(dwExStyle,"MDICLIENT",NULL,dwStyle,0,0,0,0,m_hWnd,(HMENU)IDW_PANE_FIRST,
		GetInstanceHandle(),(LPVOID)&ccs))==NULL)
	{
		return FALSE;
	}
	
	::BringWindowToTop(m_hWndMDIClient);
	return TRUE;
}
Beispiel #18
0
BOOL Taiga::InitInstance() {
  // Check another instance
  if (CheckInstance(L"Taiga-33d5a63c-de90-432f-9a8b-f6f733dab258", L"TaigaMainW"))
    return FALSE;
  g_hInstance = GetInstanceHandle();

  // Initialize
  InitCommonControls(ICC_STANDARD_CLASSES);
  OleInitialize(NULL);

  // Initialize logger
#ifdef _DEBUG
  Logger.SetOutputPath(AddTrailingSlash(GetCurrentDirectory()) + L"Taiga_debug.log");
  Logger.SetSeverityLevel(LevelDebug);
#else
  Logger.SetOutputPath(AddTrailingSlash(GetPathOnly(GetModulePath())) + L"Taiga.log");
  Logger.SetSeverityLevel(LevelWarning);
#endif

  // Load data
  LoadData();

  // Create API windows
  Skype.Create();
  TaigaApi.Create();

  if (Settings.Program.StartUp.check_new_version) {
    // Create update dialog
    ExecuteAction(L"CheckUpdates");
  } else {
    // Create main dialog
    ExecuteAction(L"MainDialog");
  }

  return TRUE;
}
STDAPI
DllRegisterServer(
    void)
{
    TCHAR szModulePath[MAX_PATH];
    BYTE pbSignature[136];  // Room for a 1024 bit signature, with padding.
    OSVERSIONINFO osVer;
    LPTSTR szFileName, szFileExt;
    HINSTANCE hThisDll;
    HRSRC hSigResource;
    DWORD dwStatus;
    LONG nStatus;
    BOOL fStatus;
    DWORD dwDisp;
    DWORD dwIndex;
    DWORD dwSigLength;
    HRESULT hReturnStatus = NO_ERROR;
    HKEY hProviders = NULL;
    HKEY hMyCsp = NULL;
    HKEY hCalais = NULL;
    HKEY hVendor = NULL;
    BOOL fSignatureFound = FALSE;
    HANDLE hSigFile = INVALID_HANDLE_VALUE;
#ifdef SCARD_CSP
    BOOL fCardIntroduced = FALSE;
    SCARDCONTEXT hCtx = NULL;
#endif

#ifdef _AFXDLL
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif


    //
    // Figure out the file name and path.
    //

    hThisDll = GetInstanceHandle();
    if (NULL == hThisDll)
    {
        hReturnStatus = HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE);
        goto ErrorExit;
    }

    dwStatus = GetModuleFileName(
                    hThisDll,
                    szModulePath,
                    sizeof(szModulePath) / sizeof(TCHAR));
    if (0 == dwStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(GetLastError());
        goto ErrorExit;
    }

    szFileName = _tcsrchr(szModulePath, TEXT('\\'));
    if (NULL == szFileName)
        szFileName = szModulePath;
    else
        szFileName += 1;
    szFileExt = _tcsrchr(szFileName, TEXT('.'));
    if (NULL == szFileExt)
    {
        hReturnStatus = HRESULT_FROM_WIN32(ERROR_INVALID_NAME);
        goto ErrorExit;
    }
    else
        szFileExt += 1;


    //
    // Create the Registry key for this CSP.
    //

    nStatus = RegCreateKeyEx(
                    HKEY_LOCAL_MACHINE,
                    TEXT("SOFTWARE\\Microsoft\\Cryptography\\Defaults\\Provider"),
                    0,
                    TEXT(""),
                    REG_OPTION_NON_VOLATILE,
                    KEY_ALL_ACCESS,
                    NULL,
                    &hProviders,
                    &dwDisp);
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }
    nStatus = RegCreateKeyEx(
                    hProviders,
                    l_szProviderName,
                    0,
                    TEXT(""),
                    REG_OPTION_NON_VOLATILE,
                    KEY_ALL_ACCESS,
                    NULL,
                    &hMyCsp,
                    &dwDisp);
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }
    nStatus = RegCloseKey(hProviders);
    hProviders = NULL;
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }


    //
    // Install the trivial registry values.
    //
	
    nStatus = RegSetValueEx(
                    hMyCsp,
                    TEXT("Image Path"),
                    0,
                    REG_SZ,
                    (LPBYTE)szModulePath,
                    (_tcslen(szModulePath) + 1) * sizeof(TCHAR));
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }

    nStatus = RegSetValueEx(
                    hMyCsp,
                    TEXT("Type"),
                    0,
                    REG_DWORD,
                    (LPBYTE)&l_dwCspType,
                    sizeof(DWORD));
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }


    //
    // See if we're self-signed.  On NT5, CSP images can carry their own
    // signatures.
    //

    hSigResource = FindResource(
                        hThisDll,
                        MAKEINTRESOURCE(CRYPT_SIG_RESOURCE_NUMBER),
                        RT_RCDATA);


    //
    // Install the file signature.
    //

    ZeroMemory(&osVer, sizeof(OSVERSIONINFO));
    osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    fStatus = GetVersionEx(&osVer);
    // ?BUGBUG? -- This works on Windows Millenium, too.
    if (fStatus
        && (VER_PLATFORM_WIN32_NT == osVer.dwPlatformId)
        && (5 <= osVer.dwMajorVersion)
        && (NULL != hSigResource))
//		&& (NULL == hSigResource))
    {

        //
        // Signature in file flag is sufficient.
        //

        dwStatus = 0;
        nStatus = RegSetValueEx(
                        hMyCsp,
                        TEXT("SigInFile"),
                        0,
                        REG_DWORD,
                        (LPBYTE)&dwStatus,
                        sizeof(DWORD));
        if (ERROR_SUCCESS != nStatus)
        {
            hReturnStatus = HRESULT_FROM_WIN32(nStatus);
            goto ErrorExit;
        }
    }
    else
    {

        //
        // We have to install a signature entry.
        // Try various techniques until one works.
        //

        for (dwIndex = 0; !fSignatureFound; dwIndex += 1)
        {
            switch (dwIndex)
            {

            //
            // Look for an external *.sig file and load that into the registry.
            //

            case 0:
                _tcscpy(szFileExt, TEXT("sig"));
                hSigFile = CreateFile(
                                szModulePath,
                                GENERIC_READ,
                                FILE_SHARE_READ,
                                NULL,
                                OPEN_EXISTING,
                                FILE_ATTRIBUTE_NORMAL,
                                NULL);
                if (INVALID_HANDLE_VALUE == hSigFile)
                    continue;
                dwSigLength = GetFileSize(hSigFile, NULL);
                if ((dwSigLength > sizeof(pbSignature))
                    || (dwSigLength < 72))      // Accept a 512-bit signature
                {
                    hReturnStatus = NTE_BAD_SIGNATURE;
                    goto ErrorExit;
                }

                fStatus = ReadFile(
                                hSigFile,
                                pbSignature,
                                sizeof(pbSignature),
                                &dwSigLength,
                                NULL);
                if (!fStatus)
                {
                    hReturnStatus = HRESULT_FROM_WIN32(GetLastError());
                    goto ErrorExit;
                }
                fStatus = CloseHandle(hSigFile);
                hSigFile = NULL;
                if (!fStatus)
                {
                    hReturnStatus = HRESULT_FROM_WIN32(GetLastError());
                    goto ErrorExit;
                }
                fSignatureFound = TRUE;
                break;


            //
            // Other cases may be added in the future.
            //

            default:
                hReturnStatus = NTE_BAD_SIGNATURE;
                goto ErrorExit;
            }

            if (fSignatureFound)
            {
                for (dwIndex = 0; dwIndex < dwSigLength; dwIndex += 1)
                {
                    if (0 != pbSignature[dwIndex])
                        break;
                }
                if (dwIndex >= dwSigLength)
                    fSignatureFound = FALSE;
            }
        }


        //
        // We've found a signature somewhere!  Install it.
        //

        nStatus = RegSetValueEx(
                        hMyCsp,
                        TEXT("Signature"),
                        0,
                        REG_BINARY,
                        pbSignature,
                        dwSigLength);
        if (ERROR_SUCCESS != nStatus)
        {
            hReturnStatus = HRESULT_FROM_WIN32(nStatus);
            goto ErrorExit;
        }
    }

    nStatus = RegCloseKey(hMyCsp);
    hMyCsp = NULL;
    if (ERROR_SUCCESS != nStatus)
    {
        hReturnStatus = HRESULT_FROM_WIN32(nStatus);
        goto ErrorExit;
    }


#ifdef SCARD_CSP
    //
    // Introduce the vendor card.  Try various techniques until one works.
    //

    for (dwIndex = 0; !fCardIntroduced; dwIndex += 1)
    {
        switch (dwIndex)
        {
        case 0:
            {
                HMODULE hWinSCard = NULL;
                LPSETCARDTYPEPROVIDERNAME pfSetCardTypeProviderName = NULL;

                hWinSCard = GetModuleHandle(TEXT("WinSCard.DLL"));
                if (NULL == hWinSCard)
                    continue;
#if defined(UNICODE)
                pfSetCardTypeProviderName =
                    (LPSETCARDTYPEPROVIDERNAME)GetProcAddress(
                        hWinSCard,
                        TEXT("SCardSetCardTypeProviderNameW"));
#else
                pfSetCardTypeProviderName =
                    (LPSETCARDTYPEPROVIDERNAME)GetProcAddress(
                        hWinSCard,
                        TEXT("SCardSetCardTypeProviderNameA"));
#endif
                if (NULL == pfSetCardTypeProviderName)
                    continue;

                dwStatus = SCardIntroduceCardType(
                                NULL,
                                l_szCardName,
                                NULL,
                                NULL,
                                0,
                                l_rgbATR,
                                l_rgbATRMask,
                                sizeof(l_rgbATR));
                if ((ERROR_SUCCESS != dwStatus)
                    && (ERROR_ALREADY_EXISTS != dwStatus))
                    continue;
                dwStatus = (*pfSetCardTypeProviderName)(
                                NULL,
                                l_szCardName,
                                SCARD_PROVIDER_CSP,
                                l_szProviderName);
                if (ERROR_SUCCESS != dwStatus)
                {
                    if (0 == (dwStatus & 0xffff0000))
                        hReturnStatus = HRESULT_FROM_WIN32(dwStatus);
                    else
                        hReturnStatus = (HRESULT)dwStatus;
                    goto ErrorExit;
                }
                fCardIntroduced = TRUE;
                break;
            }

        case 1:
            dwStatus = SCardEstablishContext(SCARD_SCOPE_SYSTEM, 0, 0, &hCtx);
            if (ERROR_SUCCESS != dwStatus)
                continue;
            dwStatus = SCardIntroduceCardType(
                            hCtx,
                            l_szCardName,
                            NULL,
                            NULL,
                            0,
                            l_rgbATR,
                            l_rgbATRMask,
                            sizeof(l_rgbATR));
            if ((ERROR_SUCCESS != dwStatus)
                && (ERROR_ALREADY_EXISTS != dwStatus))
            {
                if (0 == (dwStatus & 0xffff0000))
                    hReturnStatus = HRESULT_FROM_WIN32(dwStatus);
                else
                    hReturnStatus = (HRESULT)dwStatus;
                goto ErrorExit;
            }
            dwStatus = SCardReleaseContext(hCtx);
            hCtx = NULL;
            if (ERROR_SUCCESS != dwStatus)
            {
                if (0 == (dwStatus & 0xffff0000))
                    hReturnStatus = HRESULT_FROM_WIN32(dwStatus);
                else
                    hReturnStatus = (HRESULT)dwStatus;
                goto ErrorExit;
            }
            nStatus = RegCreateKeyEx(
                            HKEY_LOCAL_MACHINE,
                            TEXT("SOFTWARE\\Microsoft\\Cryptography\\Calais\\SmartCards"),
                            0,
                            TEXT(""),
                            REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS,
                            NULL,
                            &hCalais,
                            &dwDisp);
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegCreateKeyEx(
                            hCalais,
                            l_szCardName,
                            0,
                            TEXT(""),
                            REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS,
                            NULL,
                            &hVendor,
                            &dwDisp);
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegCloseKey(hCalais);
            hCalais = NULL;
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegSetValueEx(
                            hVendor,
                            TEXT("Crypto Provider"),
                            0,
                            REG_SZ,
                            (LPBYTE)l_szProviderName,
                            (_tcslen(l_szProviderName) + 1) * sizeof(TCHAR));
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }

            nStatus = RegCloseKey(hVendor);
            hVendor = NULL;
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }

            fCardIntroduced = TRUE;
            break;

        case 2:
            nStatus = RegCreateKeyEx(
                            HKEY_LOCAL_MACHINE,
                            TEXT("SOFTWARE\\Microsoft\\Cryptography\\Calais\\SmartCards"),
                            0,
                            TEXT(""),
                            REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS,
                            NULL,
                            &hCalais,
                            &dwDisp);
            if (ERROR_SUCCESS != nStatus)
                continue;
            nStatus = RegCreateKeyEx(
                            hCalais,
                            l_szCardName,
                            0,
                            TEXT(""),
                            REG_OPTION_NON_VOLATILE,
                            KEY_ALL_ACCESS,
                            NULL,
                            &hVendor,
                            &dwDisp);
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegCloseKey(hCalais);
            hCalais = NULL;
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegSetValueEx(
                            hVendor,
                            TEXT("Primary Provider"),
                            0,
                            REG_BINARY,
                            (LPCBYTE)&l_guidPrimaryProv,
                            sizeof(l_guidPrimaryProv));
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegSetValueEx(
                            hVendor,
                            TEXT("ATR"),
                            0,
                            REG_BINARY,
                            l_rgbATR,
                            sizeof(l_rgbATR));
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegSetValueEx(
                            hVendor,
                            TEXT("ATRMask"),
                            0,
                            REG_BINARY,
                            l_rgbATRMask,
                            sizeof(l_rgbATRMask));
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegSetValueEx(
                            hVendor,
                            TEXT("Crypto Provider"),
                            0,
                            REG_SZ,
                            (LPBYTE)l_szProviderName,
                            (_tcslen(l_szProviderName) + 1) * sizeof(TCHAR));
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            nStatus = RegCloseKey(hVendor);
            hVendor = NULL;
            if (ERROR_SUCCESS != nStatus)
            {
                hReturnStatus = HRESULT_FROM_WIN32(nStatus);
                goto ErrorExit;
            }
            fCardIntroduced = TRUE;
            break;

        default:
            hReturnStatus = ERROR_ACCESS_DENIED;
            goto ErrorExit;
        }
    }
#endif


    //
    // ?vendor?
    // Add any additional initialization required here.
    //



    //
    // All done!
    //

    return hReturnStatus;


    //
    // An error was detected.  Clean up any outstanding resources and
    // return the error.
    //

    ErrorExit:
#ifdef SCARD_CSP
    if (NULL != hCtx)
        SCardReleaseContext(hCtx);
    if (NULL != hCalais)
        RegCloseKey(hCalais);
#endif
    if (NULL != hVendor)
        RegCloseKey(hVendor);
    if (INVALID_HANDLE_VALUE != hSigFile)
        CloseHandle(hSigFile);
    if (NULL != hMyCsp)
        RegCloseKey(hMyCsp);
    if (NULL != hProviders)
        RegCloseKey(hProviders);
    DllUnregisterServer();
    return hReturnStatus;
}
INT_PTR DialogInstall::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
	case IDC_INSTALL_ADVANCED_BUTTON:
		{
			RECT r;
			GetWindowRect((HWND)lParam, &r);
			HMENU menu = LoadMenu(GetInstanceHandle(), MAKEINTRESOURCE(IDR_INSTALL_MENU));
			HMENU subMenu = GetSubMenu(menu, 0);

			if (m_PackageSkins.empty() || m_MergeSkins || m_BackupPackage)
			{
				EnableMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, MF_BYCOMMAND | MF_GRAYED);
			}
			else
			{
				CheckMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, (m_BackupSkins ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND);
			}

			if (m_PackageFonts.empty())
			{
				EnableMenuItem(subMenu, IDM_INSTALL_SYSTEMFONTS, MF_BYCOMMAND | MF_GRAYED);
			}
			else
			{
				CheckMenuItem(subMenu, IDM_INSTALL_SYSTEMFONTS, (m_SystemFonts ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND);
			}

			const WCHAR* formatName = m_PackageFormat == PackageFormat::New ? L"New format" : L"Old format";
			ModifyMenu(subMenu, IDM_INSTALL_FORMAT, MF_STRING | MF_GRAYED | MF_BYCOMMAND, IDM_INSTALL_FORMAT, formatName);

			TrackPopupMenu(
				subMenu,
				TPM_RIGHTBUTTON | TPM_LEFTALIGN,
				r.left,
				--r.bottom,
				0,
				m_Window,
				nullptr);

			DestroyMenu(menu);
		}
		break;

	case IDC_INSTALL_INSTALL_BUTTON:
		BeginInstall();
		break;

	case IDCANCEL:
		if (!m_InstallThread)
		{
			EndDialog(m_Window, 0);
		}
		break;

	case IDM_INSTALL_BACKUPSKINS:
		m_BackupSkins = !m_BackupSkins;
		break;

	case IDM_INSTALL_SYSTEMFONTS:
		m_SystemFonts = !m_SystemFonts;
		break;

	default:
		return FALSE;
	}

	return TRUE;
}
Beispiel #21
0
 VPApp(HINSTANCE hInstance)
 {
     theInstance = GetInstanceHandle();
 }
Beispiel #22
0
BOOL CShortcut::GetDefaultShortcuts(CArrayFP<CShortcut*>& aShortcuts,BYTE bLoadFlag)
{
	// This code saves currently saved shortcuts to correct file
	// Uncommend and run once

	
	/*
	// BEGIN 
	{
	LPCSTR szFile="C:\\Users\\jmhuttun\\Programming\\projects\\Locate\\Locate32\\commonres\\defaultshortcuts.dat";
	CRegKey2 RegKey;
	if (RegKey.OpenKey(HKCU,"\\General",CRegKey::defRead)!=ERROR_SUCCESS)
		return FALSE;
	DWORD dwDataLength=RegKey.QueryValueLength("Shortcuts");
	if (dwDataLength<4)
		return FALSE;
	BYTE* pData=new BYTE[dwDataLength];
	RegKey.QueryValue("Shortcuts",(LPSTR)pData,dwDataLength,NULL);
	RegKey.CloseKey();
	CFile File(TRUE);
	File.CloseOnDelete();
		

	try {
		File.Open(szFile,CFile::defWrite);
		File.Write(pData,dwDataLength);
		File.Close();
	}
	catch (...)
	{
	}
	}
	// END
	*/
	

	// Check file
	CStringW Path(GetLocateApp()->GetExeNameW());
	Path.FreeExtra(Path.FindLast(L'\\')+1);
	Path << L"defshrtc.dat";
    
	BYTE* pData=NULL;
	DWORD dwLength;
	try {
		CFile File(Path,CFile::defRead|CFile::otherErrorWhenEOF,TRUE);
		File.CloseOnDelete();

		dwLength=File.GetLength();
		pData=new BYTE[dwLength];
		File.Read(pData,dwLength);
		File.Close();
		BOOL bRet=LoadShortcuts(pData,dwLength,aShortcuts,bLoadFlag);
		delete[] pData;
		
		if (bRet)
            return TRUE;
	}
	catch (...)
	{
		if (pData!=NULL)
			delete[] pData;
	}



	HRSRC hRsrc=FindResource(GetInstanceHandle(),MAKEINTRESOURCE(IDR_DEFAULTSHORTCUTS),"DATA");
    if (hRsrc==NULL)
		return FALSE;
    	
	dwLength=SizeofResource(GetInstanceHandle(),hRsrc);
	if (dwLength<4)
		return FALSE;

	HGLOBAL hGlobal=LoadResource(GetInstanceHandle(),hRsrc);
	if (hGlobal==NULL)
		return FALSE;

	return LoadShortcuts((const BYTE*)LockResource(hGlobal),dwLength,aShortcuts,bLoadFlag);
}
Beispiel #23
0
DialogPackage::TabInfo::TabInfo(HWND wnd) : Tab(GetInstanceHandle(), wnd, IDD_PACKAGEINFO_TAB, DlgProc)
{
}
/*
** Constructor.
**
*/
DialogInstall::TabInstall::TabInstall(HWND wnd) : Tab(GetInstanceHandle(), wnd, IDD_INSTALL_TAB, DlgProc)
{
}
Beispiel #25
0
void CCSHDialog::OnWhatsThis()
{
  DisplayHelp(m_pwndContext->m_hWnd,HelpID(m_pwndContext->m_hWnd),GetInstanceHandle());
}
Beispiel #26
0
/***
 * Dialog callback for the controls property page.
 * We need to make a separate Controller object for this HWND.
 *
 * @param pWindow Handle of our window
 */
BOOL ControlPrefsPage::DlgProc(HWND pWindow, UINT pMsgId, WPARAM pWParam, LPARAM pLParam)
{
	Config *cfg = Config::GetInstance();

	InputEventController* const controller = app->GetController();

	BOOL lReturnValue = FALSE;
	switch (pMsgId) {
		// Catch environment modification events
		case WM_INITDIALOG:
			// add available maps to the drop-down box
			{
				std::vector<std::string> mapnames = controller->GetAvailableMaps();
				HWND hList = GetDlgItem(pWindow, IDC_MAP_SELECT);
				
				// add all the maps except console-keys
				for(size_t i = 0; i < mapnames.size(); i++) {
					if(mapnames.at(i) == "console-keys")
						continue; // don't add this one
					int item = SendMessage(hList, CB_ADDSTRING, 0, (LPARAM) mapnames.at(i).c_str());
				}

				// select first player map (or first map)
				std::string mapname = _("Player");
				mapname += " 1";
				int select = SendMessage(hList, CB_FINDSTRINGEXACT, -1, (LPARAM) mapname.c_str());
				SendMessage(hList, CB_SETCURSEL, (select == CB_ERR) ? 0 : select, 0); // set current item

				// now fake the message that we just changed the selection
				// (this is why there is no break at the end of this case)
				pWParam = IDC_MAP_SELECT;

				// initialize columns in ListView box
				LVCOLUMNW keycol;
				memset(&keycol, 0, sizeof(keycol));
				keycol.mask = LVCF_WIDTH | LVCF_TEXT;
				keycol.cx = 400; // 400px
				keycol.pszText = (LPWSTR) _("Action");

				LVCOLUMNW bindcol;
				memset(&bindcol, 0, sizeof(bindcol));
				bindcol.mask = LVCF_WIDTH | LVCF_TEXT;
				bindcol.cx = 135; // 135px
				bindcol.pszText = (LPWSTR) _("Binding");

				HWND listview = GetDlgItem(pWindow, IDC_CONTROL_BINDING);
				SendMessageW(listview, LVM_INSERTCOLUMN, 0, (LPARAM) &keycol);
				SendMessageW(listview, LVM_INSERTCOLUMN, 1, (LPARAM) &bindcol);

				pressAnyKeyDialog = NULL;
			}

		case WM_COMMAND:
			{
				switch(LOWORD(pWParam)) {
					// The user changed the map selection
					case IDC_MAP_SELECT:
						UpdateBindingLabels(pWindow);
						break;

					case IDC_CHANGE_BINDING:
						{
							char buffer[200];
							HWND combobox = GetDlgItem(pWindow, IDC_MAP_SELECT);
							SendMessage(combobox, WM_GETTEXT, 200, (LPARAM) &buffer);
							std::string mapname = buffer;

							// we need to populate the ListView with actions
							HWND hList = GetDlgItem(pWindow, IDC_CONTROL_BINDING);
							InputEventController::ActionMap map = controller->GetActionMap(mapname);

							// order bindings by defined ordering in ControlAction::listOrder
							std::map<int, int> orderMap;
							for(InputEventController::ActionMap::iterator it = map.begin(); it != map.end(); it++)
								orderMap[it->second->getListOrder()] = it->first;
							
							// user wants to change assigned binding
							int selectedIndex = SendMessage(hList, LVM_GETSELECTIONMARK, 0, 0);
							if(selectedIndex == -1)
								break; // apparently nothing is selected

							setControlHash = orderMap[selectedIndex];
							setControlMap = mapname;

							if(pressAnyKeyDialog == NULL) {
								WNDCLASSW lWinClass;

								lWinClass.style = CS_DBLCLKS;
								lWinClass.lpfnWndProc = PressKeyDialogFunc;
								lWinClass.cbClsExtra = 0;
								lWinClass.cbWndExtra = 0;
								lWinClass.hInstance = GetInstanceHandle();
								lWinClass.hIcon = NULL;
								lWinClass.hCursor = LoadCursor(NULL, IDC_ARROW);
								lWinClass.hbrBackground = (HBRUSH) COLOR_APPWORKSPACE + 1;
								lWinClass.lpszMenuName = NULL;
								lWinClass.lpszClassName = L"IDD_PRESS_ANY_KEY";

								lReturnValue = RegisterClassW(&lWinClass);

								// set HWND for when we get called back
								preferencesDialog = pWindow;

								RECT size = {0};
								GetWindowRect(app->GetWindowHandle(), &size);
								SetCursorPos(size.left + 110, size.top + 80); // move to center of new window

								pressAnyKeyDialog = CreateWindowW(
									L"IDD_PRESS_ANY_KEY",
									PACKAGE_NAME_L,
									(WS_POPUPWINDOW | WS_VISIBLE),
									size.left + 30,
									size.top + 30,
									160,
									100,
									app->GetWindowHandle(),
									NULL,
									GetInstanceHandle(),
									this);

								if(pressAnyKeyDialog == NULL) { // report error if necessary
									DWORD err = GetLastError();
									LPVOID errMsg;
					
									FormatMessage(
										FORMAT_MESSAGE_ALLOCATE_BUFFER |
										FORMAT_MESSAGE_FROM_SYSTEM,
										NULL,
										err,
										MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
										(LPTSTR) &errMsg,
										0, NULL);
									MessageBox(NULL, (const char*) errMsg, "AIEEE", MB_ICONERROR | MB_APPLMODAL | MB_OK);
									LocalFree(errMsg);
								}
							} else {
								// put focus back to already existing window
								EnableWindow(pWindow, false);
								EnableWindow(pressAnyKeyDialog, true);
							}
						}
						break;
				}
			}
			break;

		case WM_NOTIFY:
			switch (((NMHDR FAR *) pLParam)->code) {
				case PSN_APPLY:
					pressAnyKeyDialog = NULL;

					// reload controller
					app->ReloadController();

					cfg->Save();
					break;

				case PSN_RESET:
					pressAnyKeyDialog = NULL;
					break;

				case PSN_KILLACTIVE:
					// for receipt of PSN_APPLY
					SetWindowLong(pWindow, DWL_MSGRESULT, FALSE);
					break;
			}
	}

	return lReturnValue;
}
BOOL CCSHPropertySheet::OnHelpInfo(HELPINFO* pHelpInfo) 
{
  DisplayHelp((HWND)pHelpInfo->hItemHandle,HelpID((HWND)pHelpInfo->hItemHandle),GetInstanceHandle());
  return TRUE;
}
void CCSHPropertySheet::OnWhatsThis()
{
  DisplayHelp(m_pwndContext->m_hWnd,HelpID(m_pwndContext->m_hWnd),GetInstanceHandle());
}
Beispiel #29
0
DialogPackage::TabOptions::TabOptions(HWND wnd) : Tab(GetInstanceHandle(), wnd, IDD_PACKAGEOPTIONS_TAB, DlgProc)
{
}
Beispiel #30
0
DialogPackage::TabAdvanced::TabAdvanced(HWND wnd) : Tab(GetInstanceHandle(), wnd, IDD_PACKAGEADVANCED_TAB, DlgProc)
{
}