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

Annotation of /trunk/H7 Server/ServerInit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (hide annotations) (download)
Tue Feb 6 14:19:39 2007 UTC (17 years, 3 months ago) by hedin
File size: 1555 byte(s)
Rewritten Baud-Rate function...
1 hedin 33 #include "stdafx.h"
2     #include "Resource.h"
3     #include "H7 ServerDlg.h"
4    
5     bool CH7ServerDlg::ServerInit(void)
6     {
7 hedin 64 /////////////// </Baud Rate> \\\\\\\\\\\\\\\*/
8 hedin 33 unsigned int i;
9     // Sets values in baud-rate combo box
10     m_BaudRate.AddString("1200");
11     m_BaudRate.AddString("2400");
12     m_BaudRate.AddString("4800"); // Don't work, used for error test.
13     m_BaudRate.AddString("9600");
14     m_BaudRate.AddString("19200");
15    
16 hedin 64 m_BaudRate.SetCurSel(3); // Sets Baud-rate dropdown box to 9600.
17     /////////////// </Baud Rate> \\\\\\\\\\\\\\\*/
18 hedin 33
19     // Checks how many COM ports there are.
20     std::vector<CString> Serial = GetAvailableComPorts();
21     for (i=0; i<Serial.size(); i++)
22     m_Serial.AddString(Serial[i]);
23    
24     // Load saved settings from regedit.
25     unsigned long Port;
26    
27     // Used to format the loaded values.
28     CString TPort;
29    
30 hedin 64 CRegKey reg;
31 hedin 33 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++)
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 hedin 64 }

  ViewVC Help
Powered by ViewVC 1.1.20