/*********************************************************************** * CommConfigDialogA (KERNEL32.@) * * Raises a dialog that allows the user to configure a comm port. * Fills the COMMCONFIG struct with information specified by the user. * This function should call a similar routine in the COMM driver... * * RETURNS * * TRUE on success, FALSE on failure * If successful, the lpCommConfig structure will contain a new * configuration for the comm port, as specified by the user. * * BUGS * The library with the CommConfigDialog code is never unloaded. * Perhaps this should be done when the comm port is closed? */ BOOL WINAPI CommConfigDialogA( LPCSTR lpszDevice, /* [in] name of communications device */ HWND hWnd, /* [in] parent window for the dialog */ LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */ { LPWSTR lpDeviceW = NULL; DWORD len; BOOL r; TRACE("(%s, %p, %p)\n", debugstr_a(lpszDevice), hWnd, lpCommConfig); if (lpszDevice) { len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 ); lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len ); } r = CommConfigDialogW(lpDeviceW, hWnd, lpCommConfig); HeapFree( GetProcessHeap(), 0, lpDeviceW ); return r; }
static BOOL dlg_configure_com(HANDLE hXcv, HWND hWnd, PCWSTR pPortName) { COMMCONFIG cfg; LPWSTR shortname; DWORD status; DWORD dummy; DWORD len; BOOL res; /* strip the colon (pPortName is never empty here) */ len = lstrlenW(pPortName); shortname = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (shortname) { memcpy(shortname, pPortName, (len -1) * sizeof(WCHAR)); shortname[len-1] = '\0'; /* get current settings */ len = FIELD_OFFSET(COMMCONFIG, wcProviderData[1]); status = ERROR_SUCCESS; res = XcvDataW( hXcv, cmd_GetDefaultCommConfigW, (PBYTE) shortname, (lstrlenW(shortname) +1) * sizeof(WCHAR), (PBYTE) &cfg, len, &len, &status); if (res && (status == ERROR_SUCCESS)) { /* display the Dialog */ res = CommConfigDialogW(pPortName, hWnd, &cfg); if (res) { status = ERROR_SUCCESS; /* set new settings */ res = XcvDataW(hXcv, cmd_SetDefaultCommConfigW, (PBYTE) &cfg, len, (PBYTE) &dummy, 0, &len, &status); } } HeapFree(GetProcessHeap(), 0, shortname); return res; } return FALSE; }