/[H7]/trunk/H7 Server/ServerInit.cpp
ViewVC logotype

Contents of /trunk/H7 Server/ServerInit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations) (download)
Mon Feb 12 09:59:36 2007 UTC (17 years, 3 months ago) by hedin
File size: 1610 byte(s)
Made some cleanup and added a few comments.
1 #include "stdafx.h"
2 #include "Resource.h"
3 #include "H7 ServerDlg.h"
4
5 bool CH7ServerDlg::ServerInit(void)
6 {
7 /////////////// </Baud Rate> \\\\\\\\\\\\\\\*/
8 // Sets values in baud-rate combo box
9 m_BaudRate.AddString("1200");
10 m_BaudRate.AddString("2400");
11 m_BaudRate.AddString("4800"); // Don't work, used for error test.
12 m_BaudRate.AddString("9600");
13 m_BaudRate.AddString("19200");
14
15 m_BaudRate.SetCurSel(3); // Sets Baud-rate dropdown box to 9600.
16 /////////////// </Baud Rate> \\\\\\\\\\\\\\\*/
17
18 // Checks how many COM ports there are.
19 unsigned int i;
20 std::vector<CString> Serial = GetAvailableComPorts();
21 for (i=0; i<Serial.size(); i++)
22 m_Serial.AddString(Serial[i]);
23
24 // Bruges til at hente sidst brugte TCP port fra regedit.
25 unsigned long Port;
26
27 // int port til CString TPort
28 CString TPort;
29
30 CRegKey reg;
31 reg.Create(HKEY_LOCAL_MACHINE, "SOFTWARE\\Projekt\\Server");
32 reg.QueryDWORDValue("Port", Port);
33
34 char LoadCom[20];
35 unsigned long size = 20;
36 reg.QueryStringValue("Serial", LoadCom, &size);
37
38 TPort.Format("%d", Port);
39
40 m_Port.SetWindowText(TPort);
41 m_Serial.SetWindowText(LoadCom);
42
43 if( Serial.size() == 0 ){
44 MessageBox( "No (free) serial port's found" );
45 return false;
46 }
47 // Checks for valid COM port in regedit.
48 for (i=0; i< Serial.size() ; i++) // Serial indeholder ledige COM porte.
49 {
50 if (LoadCom == Serial[i])
51 {
52 m_Serial.SetCurSel(i);
53 break;
54 }
55 }
56 if (i == Serial.size() )
57 {
58 m_Serial.SetCurSel(0);
59 reg.SetStringValue("Serial", Serial[0]);
60 }
61 reg.Close();
62 return true;
63 }

  ViewVC Help
Powered by ViewVC 1.1.20