Skip to content

Commit ddc2879

Browse files
committed
Update config.c
1 parent b971085 commit ddc2879

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

config.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ This file is part of VCC (Virtual Color Computer).
2222
#include <commctrl.h>
2323
#include <stdio.h>
2424
#include <Richedit.h>
25+
#include <iostream>
26+
27+
#include <direct.h>
2528

2629
#include "defines.h"
2730
#include "resource.h"
@@ -38,10 +41,11 @@ This file is part of VCC (Virtual Color Computer).
3841
#include "keyboard.h"
3942
#include "fileops.h"
4043
#include "Cassette.h"
44+
#include "shlobj.h"
4145

4246
//#include "logger.h"
4347
#include <assert.h>
44-
48+
using namespace std;
4549
//
4650
// forward declarations
4751
//
@@ -62,6 +66,7 @@ LRESULT CALLBACK JoyStickConfig(HWND, UINT, WPARAM, LPARAM);
6266
LRESULT CALLBACK TapeConfig(HWND , UINT , WPARAM , LPARAM );
6367
LRESULT CALLBACK BitBanger(HWND , UINT , WPARAM , LPARAM );
6468

69+
6570
//
6671
// global variables
6772
//
@@ -79,6 +84,9 @@ static char ExecDirectory[MAX_PATH]="";
7984
static char SerialCaptureFile[MAX_PATH]="";
8085
static char TextMode=1,PrtMon=0;;
8186
static unsigned char NumberofJoysticks=0;
87+
88+
TCHAR AppDataPath[MAX_PATH];
89+
8290
char OutBuffer[MAX_PATH]="";
8391
char AppName[MAX_LOADSTRING]="";
8492
STRConfig CurrentConfig;
@@ -96,6 +104,7 @@ static JoyStick TempLeft, TempRight;
96104
static SndCardList SoundCards[MAXCARDS];
97105
static HWND hDlgBar=NULL,hDlgTape=NULL;
98106

107+
99108
CHARFORMAT CounterText;
100109
CHARFORMAT ModeText;
101110

@@ -164,10 +173,15 @@ void LoadConfig(SystemState *LCState)
164173
LoadString(NULL, IDS_APP_TITLE,AppName, MAX_LOADSTRING);
165174
GetModuleFileName(NULL,ExecDirectory,MAX_PATH);
166175
PathRemoveFileSpec(ExecDirectory);
176+
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, AppDataPath)))
177+
OutputDebugString(AppDataPath);
167178
strcpy(CurrentConfig.PathtoExe,ExecDirectory);
168-
strcpy(IniFilePath,ExecDirectory);
179+
strcat(AppDataPath, "\\VCC");
180+
if (_mkdir(AppDataPath) != 0) { OutputDebugString("Unable to create VCC config folder."); }
181+
strcpy(IniFilePath, AppDataPath);
169182
strcat(IniFilePath,"\\");
170183
strcat(IniFilePath,IniFileName);
184+
171185
LCState->ScanLines=0;
172186
NumberOfSoundCards=GetSoundCardList(SoundCards);
173187
ReadIniFile();
@@ -1058,4 +1072,4 @@ int SelectFile(char *FileName)
10581072
MessageBox(0,"Can't Open File","Can't open the file specified.",0);
10591073
strcpy(FileName,TempFileName);
10601074
return(1);
1061-
}
1075+
}

0 commit comments

Comments
 (0)