| 891 |
} |
} |
| 892 |
} |
} |
| 893 |
|
|
| 894 |
|
int DetectComPorts(char *ComPortTable, int ComPortMax) |
| 895 |
|
{ |
| 896 |
|
HMODULE h; |
| 897 |
|
TCHAR devicesBuff[65535]; |
| 898 |
|
TCHAR *p; |
| 899 |
|
int comports = 0; |
| 900 |
|
int i, j, min; |
| 901 |
|
char s; |
| 902 |
|
|
| 903 |
|
if (((h = GetModuleHandle("kernel32.dll")) != NULL) && |
| 904 |
|
(GetProcAddress(h, "QueryDosDeviceA") != NULL) && |
| 905 |
|
(QueryDosDevice(NULL, devicesBuff, 65535) != 0)) { |
| 906 |
|
p = devicesBuff; |
| 907 |
|
while (*p != '\0') { |
| 908 |
|
if (strncmp(p, "COM", 3) == 0 && p[3] != '\0') |
| 909 |
|
ComPortTable[comports++] = atoi(p+3); |
| 910 |
|
if (comports >= ComPortMax) |
| 911 |
|
break; |
| 912 |
|
p += (strlen(p)+1); |
| 913 |
|
} |
| 914 |
|
|
| 915 |
|
for (i=0; i<comports-1; i++) { |
| 916 |
|
min = i; |
| 917 |
|
for (j=i+1; j<comports; j++) |
| 918 |
|
if (ComPortTable[min] > ComPortTable[j]) |
| 919 |
|
min = j; |
| 920 |
|
if (min != i) { |
| 921 |
|
s = ComPortTable[i]; |
| 922 |
|
ComPortTable[i] = ComPortTable[min]; |
| 923 |
|
ComPortTable[min] = s; |
| 924 |
|
} |
| 925 |
|
} |
| 926 |
|
} |
| 927 |
|
else { |
| 928 |
|
#if 1 |
| 929 |
|
for (i=1; i<=ComPortMax; i++) { |
| 930 |
|
FILE *fp; |
| 931 |
|
char buf[10]; |
| 932 |
|
sprintf_s(buf, sizeof(buf), "\\\\.\\COM%d", i); |
| 933 |
|
if ((fp = fopen(buf, "r")) != NULL) { |
| 934 |
|
fclose(fp); |
| 935 |
|
ComPortTable[comports++] = i; |
| 936 |
|
} |
| 937 |
|
} |
| 938 |
|
#else |
| 939 |
|
comports = -1; |
| 940 |
|
#endif |
| 941 |
|
} |
| 942 |
|
|
| 943 |
|
return comports; |
| 944 |
|
} |
| 945 |
|
|
| 946 |
static BOOL CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam, |
static BOOL CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam, |
| 947 |
LPARAM lParam) |
LPARAM lParam) |
| 948 |
{ |
{ |
| 951 |
char EntName[7]; |
char EntName[7]; |
| 952 |
char TempHost[HostNameMaxLength + 1]; |
char TempHost[HostNameMaxLength + 1]; |
| 953 |
WORD i, j, w; |
WORD i, j, w; |
| 954 |
|
char ComPortTable[99]; |
| 955 |
|
int comports; |
| 956 |
BOOL Ok; |
BOOL Ok; |
| 957 |
#ifdef I18N |
#ifdef I18N |
| 958 |
LOGFONT logfont; |
LOGFONT logfont; |
| 1091 |
j = 0; |
j = 0; |
| 1092 |
w = 1; |
w = 1; |
| 1093 |
strcpy(EntName, "COM"); |
strcpy(EntName, "COM"); |
| 1094 |
for (i = 1; i <= GetHNRec->MaxComPort; i++) { |
if ((comports=DetectComPorts(ComPortTable, GetHNRec->MaxComPort)) >= 0) { |
| 1095 |
sprintf(&EntName[3], "%d", i); |
for (i=0; i<comports; i++) { |
| 1096 |
SendDlgItemMessage(dlg, IDC_HOSTCOM, CB_ADDSTRING, |
sprintf(&EntName[3], "%d", ComPortTable[i]); |
| 1097 |
0, (LPARAM) EntName); |
SendDlgItemMessage(dlg, IDC_HOSTCOM, CB_ADDSTRING, |
| 1098 |
j++; |
0, (LPARAM)EntName); |
| 1099 |
if (GetHNRec->ComPort == i) |
j++; |
| 1100 |
w = j; |
if (GetHNRec->ComPort == ComPortTable[i]) |
| 1101 |
|
w = j; |
| 1102 |
|
} |
| 1103 |
|
|
| 1104 |
|
} else { |
| 1105 |
|
for (i = 1; i <= GetHNRec->MaxComPort; i++) { |
| 1106 |
|
sprintf(&EntName[3], "%d", i); |
| 1107 |
|
SendDlgItemMessage(dlg, IDC_HOSTCOM, CB_ADDSTRING, |
| 1108 |
|
0, (LPARAM) EntName); |
| 1109 |
|
j++; |
| 1110 |
|
if (GetHNRec->ComPort == i) |
| 1111 |
|
w = j; |
| 1112 |
|
} |
| 1113 |
} |
} |
| 1114 |
|
|
| 1115 |
if (j > 0) |
if (j > 0) |
| 1116 |
SendDlgItemMessage(dlg, IDC_HOSTCOM, CB_SETCURSEL, w - 1, 0); |
SendDlgItemMessage(dlg, IDC_HOSTCOM, CB_SETCURSEL, w - 1, 0); |
| 1117 |
else /* All com ports are already used */ |
else /* All com ports are already used */ |
| 3908 |
|
|
| 3909 |
/* |
/* |
| 3910 |
* $Log: not supported by cvs2svn $ |
* $Log: not supported by cvs2svn $ |
| 3911 |
|
* Revision 1.56 2007/01/31 13:15:08 maya |
| 3912 |
|
* 言語ファイルがないときに \0 が正しく認識されないバグを修正した。 |
| 3913 |
|
* |
| 3914 |
* Revision 1.55 2007/01/31 04:08:39 maya |
* Revision 1.55 2007/01/31 04:08:39 maya |
| 3915 |
* メッセージを修正した。 |
* メッセージを修正した。 |
| 3916 |
* |
* |