Example #1
0
/***************************************************************************
* NAME                                                         EXPORTED
*      DevicePropertiesExA
*
* DESCRIPTION
*   Invokes the extended device properties dialog
*
* ARGUMENTS
*   hWndParent:    Handle to the parent window
*   lpMachineName: Machine Name, NULL is the local machine
*   lpDeviceID:    Specifies the device whose properties are to be shown, optional if
*                  bShowDevMgr is nonzero
*   dwFlags:       This parameter can be a combination of the following flags:
*                  * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
*                                              the default device status action button
*                                              to be clicked (Troubleshoot, Enable
*                                              Device, etc)
*   bShowDevMgr:   If non-zero it displays the device manager instead of
*                  the advanced device property dialog
*
* RETURN VALUE
*   1:  if bShowDevMgr is non-zero and no error occured
*   -1: a call to GetLastError returns 0 if successful
*
* @implemented
*/
INT_PTR
WINAPI
DevicePropertiesExA(IN HWND hWndParent  OPTIONAL,
                    IN LPCSTR lpMachineName  OPTIONAL,
                    IN LPCSTR lpDeviceID  OPTIONAL,
                    IN DWORD dwFlags  OPTIONAL,
                    IN BOOL bShowDevMgr)
{
    LPWSTR lpMachineNameW = NULL;
    LPWSTR lpDeviceIDW = NULL;
    INT_PTR Ret = -1;

    if (lpMachineName != NULL)
    {
        if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
                                                         CP_ACP)))
        {
            goto Cleanup;
        }
    }
    if (lpDeviceID != NULL)
    {
        if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
                                                      CP_ACP)))
        {
            goto Cleanup;
        }
    }

    Ret = DevicePropertiesExW(hWndParent,
                              lpMachineNameW,
                              lpDeviceIDW,
                              dwFlags,
                              bShowDevMgr);

Cleanup:
    if (lpMachineNameW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpMachineNameW);
    }
    if (lpDeviceIDW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpDeviceIDW);
    }

    return Ret;
}
Example #2
0
/***************************************************************************
* NAME                                                         EXPORTED
*      DeviceManager_ExecuteA
*
* DESCRIPTION
*   Starts the Device Manager
*
* ARGUMENTS
*   hWndParent:   Handle to the parent window
*   hInst:        Handle to the application instance
*   lpMachineName: Machine Name, NULL is the local machine
*   nCmdShow:      Specifies how the window should be shown
*
* RETURN VALUE
*   TRUE:  if no errors occured
*   FALSE: if the device manager could not be executed
*
* REVISIONS
*
* NOTE
*   - Win runs the device manager in a separate process, so hWndParent is somehow
*     obsolete.
*
* @implemented
*/
BOOL
WINAPI
DeviceManager_ExecuteA(HWND hWndParent,
                       HINSTANCE hInst,
                       LPCSTR lpMachineName,
                       int nCmdShow)
{
    LPWSTR lpMachineNameW = NULL;
    BOOL Ret;

    if (lpMachineName != NULL)
    {
        if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
                                                         CP_ACP)))
        {
            return FALSE;
        }
    }

    Ret = DeviceManager_ExecuteW(hWndParent,
                                 hInst,
                                 lpMachineNameW,
                                 nCmdShow);

    if (lpMachineNameW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpMachineNameW);
    }


    return Ret;
}
Example #3
0
/***************************************************************************
* NAME                                                         EXPORTED
*      DeviceProperties_RunDLLA
*
* DESCRIPTION
*   Invokes the device properties dialog
*
* ARGUMENTS
*   hWndParent:  Handle to the parent window
*   hInst:       Handle to the application instance
*   lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
*                also see NOTEs
*   nCmdShow:    Specifies how the window should be shown
*
* RETURN VALUE
*
* REVISIONS
*
* NOTE
*   - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
*     (/MachineName is optional). This function only parses this string and eventually
*     calls DeviceProperties().
*
* @implemented
*/
VOID
WINAPI
DeviceProperties_RunDLLA(HWND hWndParent,
                         HINSTANCE hInst,
                         LPCSTR lpDeviceCmd,
                         int nCmdShow)
{
    LPWSTR lpDeviceCmdW = NULL;

    if (lpDeviceCmd != NULL)
    {
        if ((lpDeviceCmdW = ConvertMultiByteToUnicode(lpDeviceCmd,
                                                      CP_ACP)))
        {
            DeviceProperties_RunDLLW(hWndParent,
                                     hInst,
                                     lpDeviceCmdW,
                                     nCmdShow);
        }
    }

    if (lpDeviceCmdW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpDeviceCmdW);
    }
}
Example #4
0
static void	RomDialog_Update(HWND hRomDialog)
{
	const int *pArray = Rom_UpdateArray;
	int i;

	for (i=0; i<NUM_ROMS; i++)
	{
		char *pName;

		if (ExpansionRom_GetRomName(i+1, &pName))
		{
#ifdef _UNICODE
			TCHAR *sUnicodeName = ConvertMultiByteToUnicode(pName);

			if (sUnicodeName)
			{
				SetDlgItemText(hRomDialog,pArray[0],sUnicodeName);

				free(sUnicodeName);
			}
#else
			SetDlgItemText(hRomDialog,pArray[0],pName);
#endif

			free(pName);
		}
		else
		{
			SetDlgItemText(hRomDialog,pArray[0],_T("EMPTY SLOT"));
		}
		pArray++;
		SetCheckButtonState(hRomDialog, pArray[0], ExpansionRom_IsActive(i+1));
		pArray++;
	}
}
Example #5
0
/***************************************************************************
* NAME                                                         EXPORTED
*      DeviceAdvancedPropertiesA
*
* DESCRIPTION
*   Invokes the device properties dialog, this version may add some property pages
*   for some devices
*
* ARGUMENTS
*   hWndParent:    Handle to the parent window
*   lpMachineName: Machine Name, NULL is the local machine
*   lpDeviceID:    Specifies the device whose properties are to be shown
*
* RETURN VALUE
*   Always returns -1, a call to GetLastError returns 0 if successful
*
* @implemented
*/
INT_PTR
WINAPI
DeviceAdvancedPropertiesA(IN HWND hWndParent  OPTIONAL,
                          IN LPCSTR lpMachineName  OPTIONAL,
                          IN LPCSTR lpDeviceID)
{
    LPWSTR lpMachineNameW = NULL;
    LPWSTR lpDeviceIDW = NULL;
    INT_PTR Ret = -1;

    if (lpMachineName != NULL)
    {
        if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
                                                         CP_ACP)))
        {
            goto Cleanup;
        }
    }
    if (lpDeviceID != NULL)
    {
        if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
                                                      CP_ACP)))
        {
            goto Cleanup;
        }
    }

    Ret = DeviceAdvancedPropertiesW(hWndParent,
                                    lpMachineNameW,
                                    lpDeviceIDW);

Cleanup:
    if (lpMachineNameW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpMachineNameW);
    }
    if (lpDeviceIDW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpDeviceIDW);
    }

    return Ret;
}
Example #6
0
/***************************************************************************
 * NAME                                                         EXPORTED
 *      DeviceProblemWizardA
 *
 * DESCRIPTION
 *   Calls the device problem wizard
 *
 * ARGUMENTS
 *   hWndParent:    Handle to the parent window
 *   lpMachineName: Machine Name, NULL is the local machine
 *   lpDeviceID:    Specifies the device, also see NOTEs
 *
 * RETURN VALUE
 *   TRUE:  if no errors occured
 *   FALSE: if errors occured
 *
 * @implemented
 */
BOOL
WINAPI
DeviceProblemWizardA(IN HWND hWndParent  OPTIONAL,
                     IN LPCSTR lpMachineName  OPTIONAL,
                     IN LPCSTR lpDeviceID)
{
    LPWSTR lpMachineNameW = NULL;
    LPWSTR lpDeviceIDW = NULL;
    BOOL Ret = FALSE;

    if (lpMachineName != NULL)
    {
        if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
                                                         CP_ACP)))
        {
            goto Cleanup;
        }
    }
    if (lpDeviceID != NULL)
    {
        if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
                                                      CP_ACP)))
        {
            goto Cleanup;
        }
    }

    Ret = DeviceProblemWizardW(hWndParent,
                               lpMachineNameW,
                               lpDeviceIDW);

Cleanup:
    if (lpMachineNameW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpMachineNameW);
    }
    if (lpDeviceIDW != NULL)
    {
        HeapFree(GetProcessHeap(),
                 0,
                 lpDeviceIDW);
    }

    return Ret;
}
Example #7
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	RECT rect;
	static HFONT hFont;

	switch (message)
	{
	case WM_CREATE:
		hFont = CreateFont(24, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, 0, 0, 0, ANTIALIASED_QUALITY, 0, L"Segoeui");
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		//case IDM_ABOUT:
		//	DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
		//	break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case IDM_FILE_CONVERT:
			ShowSuccess( ConvertMultiByteToUnicode(DEFAULT_CODEPAGE) );
			break;
		case IDM_FILE_CONVERTTEXTFILE:
			ShowSuccess( ConvertTextFileToUnicode(DEFAULT_CODEPAGE) );
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code here...
		SelectObject(hdc, hFont);
		
		GetClientRect(hWnd, &rect);
		DrawText(hdc, lpSource, _tcslen(lpSource), &rect, DT_WORDBREAK);
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		DeleteObject(hFont);
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}