serialui: Fix return type for CommConfigDialog.

This commit is contained in:
Detlef Riekenberg 2007-03-06 05:40:56 +01:00 committed by Alexandre Julliard
parent 2253edb7a3
commit 20a3298312
2 changed files with 44 additions and 42 deletions

View file

@ -1194,23 +1194,20 @@ BOOL WINAPI CommConfigDialogA(
HWND hWnd, /* [in] parent window for the dialog */ HWND hWnd, /* [in] parent window for the dialog */
LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */ LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */
{ {
FARPROC lpfnCommDialog; LPWSTR lpDeviceW = NULL;
HMODULE hConfigModule; DWORD len;
BOOL r = FALSE; BOOL r;
TRACE("(%s, %p, %p)\n", debugstr_a(lpszDevice), hWnd, lpCommConfig); TRACE("(%s, %p, %p)\n", debugstr_a(lpszDevice), hWnd, lpCommConfig);
hConfigModule = LoadLibraryW(lpszSerialUI); if (lpszDevice)
if(!hConfigModule) {
return FALSE; len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 );
lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
lpfnCommDialog = GetProcAddress(hConfigModule, "drvCommConfigDialogA"); MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len );
}
if(lpfnCommDialog) r = CommConfigDialogW(lpDeviceW, hWnd, lpCommConfig);
r = lpfnCommDialog(lpszDevice,hWnd,lpCommConfig); HeapFree( GetProcessHeap(), 0, lpDeviceW );
FreeLibrary(hConfigModule);
return r; return r;
} }
@ -1224,24 +1221,23 @@ BOOL WINAPI CommConfigDialogW(
HWND hWnd, /* [in] parent window for the dialog */ HWND hWnd, /* [in] parent window for the dialog */
LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */ LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */
{ {
FARPROC lpfnCommDialog; FARPROC pCommConfigDialog;
HMODULE hConfigModule; HMODULE hConfigModule;
BOOL r = FALSE; DWORD res = ERROR_INVALID_PARAMETER;
TRACE("(%s, %p, %p)\n", debugstr_w(lpszDevice), hWnd, lpCommConfig); TRACE("(%s, %p, %p)\n", debugstr_w(lpszDevice), hWnd, lpCommConfig);
hConfigModule = LoadLibraryW(lpszSerialUI); hConfigModule = LoadLibraryW(lpszSerialUI);
if(!hConfigModule)
return FALSE;
lpfnCommDialog = GetProcAddress(hConfigModule, "drvCommConfigDialogW"); if (hConfigModule) {
pCommConfigDialog = GetProcAddress(hConfigModule, "drvCommConfigDialogW");
if (pCommConfigDialog) {
res = pCommConfigDialog(lpszDevice, hWnd, lpCommConfig);
}
FreeLibrary(hConfigModule);
}
if(lpfnCommDialog) if (res) SetLastError(res);
r = lpfnCommDialog(lpszDevice,hWnd,lpCommConfig); return (res == ERROR_SUCCESS);
FreeLibrary(hConfigModule);
return r;
} }
/*********************************************************************** /***********************************************************************

View file

@ -376,10 +376,10 @@ static INT_PTR CALLBACK SERIALUI_ConfigDialogProc(HWND hWnd, UINT uMsg, WPARAM w
{ {
case IDOK: case IDOK:
SERIALUI_DialogInfoToDCB(hWnd,info); SERIALUI_DialogInfoToDCB(hWnd,info);
EndDialog(hWnd,1); EndDialog(hWnd, ERROR_SUCCESS);
return TRUE; return TRUE;
case IDCANCEL: case IDCANCEL:
EndDialog(hWnd,0); EndDialog(hWnd, ERROR_CANCELLED);
return TRUE; return TRUE;
/* test code for Get/SetDefaultCommConfig begins */ /* test code for Get/SetDefaultCommConfig begins */
case ID_GETDEFAULT: case ID_GETDEFAULT:
@ -431,38 +431,44 @@ static VOID SERIALUI_strfree( LPWSTR strW )
/*********************************************************************** /***********************************************************************
* drvCommConfigDialogW (SERIALUI.@) * drvCommConfigDialogW (SERIALUI.@)
* *
* Used by Win9x KERNEL to show a dialog for configuring a COMM port. * Show a dialog for configuring a Serial Port.
*
*/ */
BOOL WINAPI drvCommConfigDialogW( DWORD WINAPI drvCommConfigDialogW(LPCWSTR lpszName, HWND hWndParent, LPCOMMCONFIG lpCommConfig)
LPCWSTR lpszName, {
HWND hWndParent,
LPCOMMCONFIG lpCommConfig
) {
SERIALUI_DialogInfo info; SERIALUI_DialogInfo info;
INT res;
info.lpCommConfig = lpCommConfig; info.lpCommConfig = lpCommConfig;
info.lpszDevice = lpszName; info.lpszDevice = lpszName;
info.bConvert = FALSE; info.bConvert = FALSE;
info.dwFlowControl = 0; info.dwFlowControl = 0;
if(!lpCommConfig) if ((!lpCommConfig) || (!lpszName))
return FALSE; return ERROR_INVALID_PARAMETER;
return DialogBoxParamW(SERIALUI_hModule, if (lpCommConfig->dwSize < sizeof(COMMCONFIG))
return ERROR_INSUFFICIENT_BUFFER;
if (!lpszName[0])
return ERROR_BADKEY;
res = DialogBoxParamW( SERIALUI_hModule,
MAKEINTRESOURCEW(IDD_SERIALUICONFIG), MAKEINTRESOURCEW(IDD_SERIALUICONFIG),
hWndParent, hWndParent,
SERIALUI_ConfigDialogProc, SERIALUI_ConfigDialogProc,
(LPARAM)&info); (LPARAM)&info);
return (res == -1) ? GetLastError() : res ;
} }
/*********************************************************************** /***********************************************************************
* drvCommConfigDialogA (SERIALUI.@) * drvCommConfigDialogA (SERIALUI.@)
*/ */
BOOL WINAPI drvCommConfigDialogA( DWORD WINAPI drvCommConfigDialogA(LPCSTR lpszName, HWND hWndParent, LPCOMMCONFIG lpCommConfig)
LPCSTR lpszName, HWND hWndParent, LPCOMMCONFIG lpCommConfig )
{ {
LPWSTR strW = SERIALUI_strdup( lpszName ); LPWSTR strW = SERIALUI_strdup( lpszName );
BOOL r = drvCommConfigDialogW( strW, hWndParent, lpCommConfig ); DWORD r = drvCommConfigDialogW( strW, hWndParent, lpCommConfig );
SERIALUI_strfree( strW ); SERIALUI_strfree( strW );
return r; return r;
} }
@ -560,7 +566,8 @@ DWORD WINAPI drvGetDefaultCommConfigW(
r = sizeof(comW) / sizeof(WCHAR); /* len of "com\0" */ r = sizeof(comW) / sizeof(WCHAR); /* len of "com\0" */
lstrcpynW(szKeyName, lpszDevice, r); /* simulate a lstrcmpnW */ lstrcpynW(szKeyName, lpszDevice, r); /* simulate a lstrcmpnW */
r--; r--;
if( lstrcmpW(szKeyName, comW) ||
if( lstrcmpiW(szKeyName, comW) ||
(lpszDevice[r] < '1') || (lpszDevice[r] > '9') || lpszDevice[r+1]) { (lpszDevice[r] < '1') || (lpszDevice[r] > '9') || lpszDevice[r+1]) {
return ERROR_BADKEY; return ERROR_BADKEY;
} }
@ -593,7 +600,6 @@ DWORD WINAPI drvGetDefaultCommConfigW(
else else
{ {
/* FIXME: default to a hardcoded commconfig */ /* FIXME: default to a hardcoded commconfig */
lpCommConfig->dcb.DCBlength = sizeof(DCB); lpCommConfig->dcb.DCBlength = sizeof(DCB);
lpCommConfig->dcb.BaudRate = 9600; lpCommConfig->dcb.BaudRate = 9600;
lpCommConfig->dcb.fBinary = TRUE; lpCommConfig->dcb.fBinary = TRUE;