Kod: Markera allt
if(Input >= 1000)
{
if(Input >= 1000000)
{
// Skriv ut i MHz
}
else
{
// Skriv ut i kHz
}
}
else
{
// Skriv ut i Hz
}
Kod: Markera allt
if(Input >= 1000)
{
if(Input >= 1000000)
{
// Skriv ut i MHz
}
else
{
// Skriv ut i kHz
}
}
else
{
// Skriv ut i Hz
}
Kod: Markera allt
struct
{
char COM_Port[6];
BOOL Keep_Open;
char FlashFiles[5][MAXPATH];
char Default_Remote;
} Config;
char ConfigFile[MAXPATH];
Start av program:
strncpy(ConfigFile,__argv[0],sizeof(ConfigFile)); // Copy the program name
*strrchr(ConfigFile,'.') = 0; // Put in an End-Of-Line
sprintf(&ConfigFile[strlen(ConfigFile)],".ini"); // Alter extension to ".ini"
// Now the ConfigFile contains the name and path to the config-file
void __fastcall TForm1::LoadConfigFile(void)
{
HANDLE Handle;
DWORD Did_Read;
HANDLE Handle;
Handle = CreateFile(ConfigFile,GENERIC_READ,0,0,OPEN_EXISTING,0,0); // Open it if it exists
if(Handle != INVALID_HANDLE_VALUE)
{
ReadFile(Handle,&Config,sizeof(Config),&DidRead,0);
CloseHandle(Handle);
// Now the datas are read from file into Config-struct.
}
else
{
// Default setting needs to be activated as no config-file is found
}
}
void __fastcall TForm1::SaveConfigFile(void)
{
HANDLE Handle;
DWORD Did_Write;
Handle = CreateFile(ConfigFile,GENERIC_WRITE,0,0,CREATE_ALWAYS,0,0); // Make a new!
if(Handle != INVALID_HANDLE_VALUE)
{
WriteFile(Handle,&Config,sizeof(Config),&Did_Write,0);
CloseHandle(Handle);
}
}
Kod: Markera allt
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (serialPort1.IsOpen) serialPort1.Close();
}