@@ -50,7 +50,6 @@ CInit::CInit()
50
50
, m_nSearchTarget(0 )
51
51
, m_nSearchLogic(0 )
52
52
, m_bReadOnly(false )
53
- , m_strIniFile(_T(" " ))
54
53
, m_strStateFile(_T(" " ))
55
54
, m_strSettingsFile(_T(" " ))
56
55
, m_hHookDLL(nullptr )
@@ -68,7 +67,9 @@ CInit::CInit()
68
67
// ---------------------------------------------------
69
68
CInit::~CInit ()
70
69
{
71
- if (m_hHookDLL) unHook ();
70
+ if (m_hHookDLL) {
71
+ unHook ();
72
+ }
72
73
}
73
74
74
75
// ---------------------------------------------------
@@ -85,7 +86,7 @@ void CInit::initialize()
85
86
86
87
// user name
87
88
DWORD dwSize = _countof (buf);
88
- if (::GetUserName (buf, &dwSize)) {
89
+ if (::GetUserName (buf, &dwSize)) {
89
90
m_strUserName = CString (buf);
90
91
}
91
92
else {
@@ -108,7 +109,6 @@ void CInit::initialize()
108
109
}
109
110
110
111
// file paths for state, settings and log
111
- m_strIniFile = m_strAppDataPath + " \\ " + INI_FILE;
112
112
m_strStateFile = m_strAppDataPath + " \\ " + STATE_FILE;
113
113
m_strSettingsFile = m_strAppDataPath + " \\ " + SETTINGS_FILE;
114
114
m_strDebugLog = m_strAppDataPath + " \\ " + DEBUGLOG_FILE;
@@ -117,182 +117,6 @@ void CInit::initialize()
117
117
try { m_state = nlohmann::json::parse (std::ifstream (m_strStateFile)); }
118
118
catch (...) {}
119
119
120
- // read settings
121
- try { m_settings = nlohmann::json::parse (std::ifstream (m_strSettingsFile)); }
122
- catch (...) {}
123
-
124
- // if(m_strIniFile == "") return;
125
-
126
- // int i;
127
- // //int nKetsetCount;
128
- // CString strKeyBuff,StringBuff;
129
- // CString strRes;
130
- // CHANGE_KEY key;
131
- // TCHAR strBuff[1024],*szName,*szKind,*szMacro;
132
-
133
- // 一般設定
134
- // m_etc.m_nActiveTime = setIniFileInt(REGKEY_ETC,_T("ActiveTime"),400); //監視タイマー
135
- // m_etc.m_nCopyRetryTimes = setIniFileInt(REGKEY_ETC,_T("CopyWaitCnt"),5);
136
- // m_etc.m_nPasteRetryTimes = setIniFileInt(REGKEY_ETC,_T("PasteWaitCnt"),10);
137
-
138
- // m_pop.m_nDCKeyPopTime = setIniFileInt(REGKEY_POPUP,_T("DCPopupKeyTime"),250);
139
- // m_pop.m_nDCKeyFifoTime = setIniFileInt(REGKEY_POPUP,_T("DCFifoKeyTime"),250);
140
-
141
- // m_nToolTipTime = setIniFileInt(REGKEY_ENV, _T("ToolTipTime"), 30000);
142
- // m_nToolTipDelay = setIniFileInt(REGKEY_ENV, _T("ToolTipDelay"), 300);
143
-
144
- // 履歴FIFO設定
145
- // m_fifo.m_nFifo = setIniFileInt(REGKEY_FIFO,_T("FifoSW"),1); //履歴動作中はCtrl+Vで貼り付ける文字列を先入れ先出しにする 0NON 1FIFO 2RIFO
146
- // m_fifo.m_strCopySound = setIniFileString(REGKEY_FIFO,_T("WaveName"),_T("pu.wav"));
147
- // m_fifo.m_nOffClear = setIniFileInt(REGKEY_FIFO,_T("OffClear"),0); //履歴OFF時に一時項目をクリア
148
- // m_fifo.m_nAllClearOff = setIniFileInt(REGKEY_FIFO,_T("AllClearOff"),1);//一時履歴が空になったら履歴モードをOFFにする
149
- // m_fifo.m_nDuplication = setIniFileInt(REGKEY_FIFO,_T("Duplication"),1);
150
-
151
- // //仮想キー設定
152
- // WINDOWS_MESSAGE winMessage;
153
- // // m_key.m_defKeySet.m_nMessage = setIniFileInt(REGKEY_KEY,_T("isMessage"),0); // obsolete
154
- // m_key.m_defKeySet.m_nMessage = 0; //メッセージ方式
155
- // m_key.m_defKeySet.m_uMod_Paste = setIniFileInt(REGKEY_KEY,_T("ModPaste"),MOD_CONTROL); //貼り付け特殊キー
156
- // m_key.m_defKeySet.m_uVK_Paste = setIniFileInt(REGKEY_KEY,_T("VKPaste"),'V'); //貼り付けキー
157
- // m_key.m_defKeySet.m_uMod_Copy = setIniFileInt(REGKEY_KEY,_T("ModCopy"),MOD_CONTROL); //コピー特殊キー
158
- // m_key.m_defKeySet.m_uVK_Copy = setIniFileInt(REGKEY_KEY,_T("VkCopy"),'C'); //コピーキー
159
- // m_key.m_defKeySet.m_nCopyWait = setIniFileInt(REGKEY_KEY,_T("CopyWait"),50); //コピー待ち時間
160
- // m_key.m_defKeySet.m_nPasteWait = setIniFileInt(REGKEY_KEY,_T("PasteWait"),50); //ペースト待ち時間
161
- // //メッセージ
162
- // strKeyBuff = setIniFileString(REGKEY_KEY,_T("CopyMessage"),_T("301,0,0"));
163
- // _stscanf_s(LPCTSTR(strKeyBuff),_T("%x,%x,%x"),&winMessage.Msg,&winMessage.wParam,&winMessage.lParam);
164
- // m_key.m_defKeySet.m_copyMessage = winMessage;
165
-
166
- // strKeyBuff = setIniFileString(REGKEY_KEY,_T("PasteMessage"),_T("302,0,0"));
167
- // _stscanf_s(LPCTSTR(strKeyBuff),_T("%x,%x,%x"),&winMessage.Msg,&winMessage.wParam,&winMessage.lParam);
168
- // m_key.m_defKeySet.m_pasteMessage = winMessage;
169
- // //クリップボード容量制限
170
- // m_key.m_nHistoryLimit = setIniFileInt(REGKEY_KEY,_T("HistoryLimit"),-1);
171
-
172
- // //固有キー設定を読む
173
- // nKetsetCount = setIniFileInt(REGKEY_KEY,_T("KeySetCount"),0);
174
- // m_key.m_KeyList.clear();
175
- // for(i = 0; i < nKetsetCount; i++){
176
- // StringBuff.Format(_T("KeySetTitle_%d"),i);
177
- // //ウィンドウキャプション
178
- // key.m_strTitle = setIniFileString(REGKEY_KEY,StringBuff,_T(""));
179
- // //マッチ方法
180
- // StringBuff.Format(_T("KeySetMatch_%d"),i);
181
- // key.m_nMatch = setIniFileInt(REGKEY_KEY,StringBuff,0);
182
- // //キーコード
183
- // StringBuff.Format(_T("KeySetCode_%d"),i);
184
- // strKeyBuff = setIniFileString(REGKEY_KEY,StringBuff,"");
185
- // _stscanf_s(LPCTSTR(strKeyBuff),_T("%d,%d,%d,%d")
186
- // ,&key.m_sCopyPasteKey.m_uMod_Copy,&key.m_sCopyPasteKey.m_uVK_Copy
187
- // ,&key.m_sCopyPasteKey.m_uMod_Paste,&key.m_sCopyPasteKey.m_uVK_Paste);
188
- // StringBuff.Format(_T("KeyCopyWait_%d"),i);
189
- // key.m_sCopyPasteKey.m_nCopyWait = setIniFileInt(REGKEY_KEY,StringBuff,100); //コピー待ち時間
190
- // StringBuff.Format(_T("KeyPasteWait_%d"),i);
191
- // key.m_sCopyPasteKey.m_nPasteWait = setIniFileInt(REGKEY_KEY,StringBuff,100); //ペースト待ち時間
192
-
193
- // StringBuff.Format(_T("KeyMessage_%d"),i);
194
- // key.m_sCopyPasteKey.m_nMessage = setIniFileInt(REGKEY_KEY,StringBuff,0); //方式
195
-
196
- // //メッセージ
197
- // StringBuff.Format(_T("CopyMessage_%d"),i);
198
- // strKeyBuff = setIniFileString(REGKEY_KEY,StringBuff,_T("301,0,0"));
199
- // _stscanf_s(LPCTSTR(strKeyBuff),_T("%x,%x,%x"),&winMessage.Msg,&winMessage.wParam,&winMessage.lParam);
200
- // key.m_sCopyPasteKey.m_copyMessage = winMessage;
201
- //
202
- // StringBuff.Format(_T("PasteMessage_%d"),i);
203
- // strKeyBuff = setIniFileString(REGKEY_KEY,StringBuff,_T("302,0,0"));
204
- // _stscanf_s(LPCTSTR(strKeyBuff),_T("%x,%x,%x"),&winMessage.Msg,&winMessage.wParam,&winMessage.lParam);
205
- // key.m_sCopyPasteKey.m_pasteMessage = winMessage;
206
- // //クリップボード容量制限
207
- // StringBuff.Format(_T("HistoryLimit_%d"),i);
208
- // key.m_nHistoryLimit = setIniFileInt(REGKEY_KEY,StringBuff,-1);
209
- //
210
- // m_key.m_KeyList.insert(m_key.m_KeyList.end(),key);//設定に追加
211
- // }
212
-
213
- // 一般環境設定
214
- // m_strDataPath = setIniFileString(REGKEY_ENV,_T("DataFile"),"");
215
-
216
- // m_strRwPluginFolder = setIniFileString(REGKEY_ENV,_T("RwPluginFolder"),m_strAppPath + _T("RW_Plugin"));
217
- // m_strPluginName = setIniFileString(REGKEY_ENV,_T("DataFormat"),DAT_FORMAT);
218
- // m_strMacroPluginName = setIniFileString(REGKEY_ENV,_T("MacroPlugin"),DAT_FORMAT);
219
- // m_nSelectID = setIniFileInt(REGKEY_ENV,_T("SelectID"),-1);
220
- // time_t lTime;
221
- // m_nTreeID = setIniFileInt(REGKEY_ENV,_T("TreeID"),time(&lTime));
222
- // m_nRecNumber = setIniFileInt(REGKEY_ENV,_T("RecNumber"),0);
223
- // m_nDebug = setIniFileInt(REGKEY_ENV,_T("Debug"),0) != 0;
224
- // m_strDebugLog = setIniFileString(REGKEY_ENV,_T("LogfileName"),_T("Charu3.log"));
225
-
226
- // ウィンドウ設定
227
- // m_DialogSize.x = setIniFileInt(REGKEY_WINDOW,_T("PopupSizeX"),250);
228
- // m_DialogSize.y = setIniFileInt(REGKEY_WINDOW,_T("PopupSizeY"),350);
229
-
230
- // 検索設定
231
- // m_nSearchTarget = setIniFileInt(REGKEY_SERCH,_T("SerchKind"),0);
232
- // m_nSearchLogic = setIniFileInt(REGKEY_SERCH,_T("SerchLogic"),0);
233
- // m_strSearchKey = setIniFileString(REGKEY_SERCH,_T("SerchKey"),_T(""));
234
-
235
- // マクロテンプレート
236
- // for(i = 0; i <= 99; i++) { // TODO: magic number
237
- // strRes.LoadString(APP_INF_MACRO_TEMPLATE01+i);
238
- // if(strRes == _T("end")) break;
239
- // }
240
- // int nStringCnt = i;
241
- MACRO_STRUCT macroData;
242
- CString strMacro;
243
- // m_vctMacro.clear();
244
- // m_vctMacro.reserve(99); // TODO: magic number
245
- // for(i = 1; i <= 99; i++) { // TODO: magic number
246
- // StringBuff.Format(_T("Macro_%02d"),i);
247
- // ::GetPrivateProfileString(REGKEY_MACRO,StringBuff,_T(""),strBuff,_countof(strBuff),m_strIniFile);
248
- // if (_tcsclen(strBuff) == 0 && i <= nStringCnt) {
249
- // strRes.LoadString(APP_INF_MACRO_TEMPLATE01 + i -1);
250
- // writeProfileString(REGKEY_MACRO,StringBuff,strRes);
251
- // strMacro = strRes;
252
- // _tcscpy_s(strBuff,LPCTSTR(strRes));
253
- // }
254
- // if(_tcsclen(strBuff) == 0) break;
255
- // if(UStringWork::splitString(strBuff,_T('@'),&szName,&szKind,&szMacro,NULL) == 3) {
256
- // macroData.m_strName = szName;
257
- // if(*szKind == _T('D')) macroData.m_cKind = KIND_DATA_ALL;
258
- // else if(*szKind == _T('F')) macroData.m_cKind = KIND_FOLDER_ALL;
259
- // else macroData.m_cKind = 0xff;
260
- // macroData.m_strMacro = szMacro;
261
- // m_vctMacro.push_back(macroData);
262
- // }
263
- // }
264
-
265
- // 拡張マクロテンプレート R履歴フォルダ Fフォルダ A全て Dデータ
266
- // for(i = 0; i <= 99; i++) { // TODO: magic number
267
- // strRes.LoadString(APP_INF_EXMACRO_TEMPLATE01+i);
268
- // if(strRes == "end") break;
269
- // }
270
- // int nStringCnt = i;
271
- // m_vctDataMacro.clear();
272
- // m_vctDataMacro.reserve(99); // TODO: magic number
273
- // for(i = 1; i <= 99; i++) { // TODO: magic number
274
- // StringBuff.Format(_T("DataMacro_%02d"),i);
275
- // ::GetPrivateProfileString(REGKEY_MACRO,StringBuff,_T(""),strBuff,_countof(strBuff),m_strIniFile);
276
- // if (_tcsclen(strBuff) == 0 && i <= nStringCnt) {
277
- // strRes.LoadString(APP_INF_EXMACRO_TEMPLATE01 + i -1);
278
- // writeProfileString(REGKEY_MACRO,StringBuff,strRes);
279
- // strMacro = strRes;
280
- // _tcscpy_s(strBuff,LPCTSTR(strRes));
281
- // }
282
- // if(_tcsclen(strBuff) == 0) break;
283
- // if(UStringWork::splitString(strBuff,'@',&szName,&szKind,&szMacro,NULL) == 3) {
284
- // macroData.m_strName = szName;
285
- // if(*szKind == 'D') macroData.m_cKind = KIND_DATA_ALL;
286
- // else if(*szKind == 'R') macroData.m_cKind = KIND_RIREKI;
287
- // else if(*szKind == 'F') macroData.m_cKind = KIND_FOLDER_ALL;
288
- // else macroData.m_cKind = 0xff;
289
- // macroData.m_strMacro = szMacro;
290
- // m_vctDataMacro.push_back(macroData);
291
- // }
292
- // }
293
-
294
- // read state
295
-
296
120
m_strDataPath = CGeneral::getSettingCString (m_state, " data.path" , _T (" " ));
297
121
m_strDataFormat = CGeneral::getSettingCString (m_state, " data.format" , DAT_FORMAT);
298
122
m_bReadOnly = CGeneral::getSettingBool (m_state, " data.readOnly" , false );
@@ -309,6 +133,8 @@ void CInit::initialize()
309
133
m_nRecNumber = static_cast <int >(CGeneral::getSettingNumber (m_state, " internal.recordNumber" , 0 ));
310
134
311
135
// read settings
136
+ try { m_settings = nlohmann::json::parse (std::ifstream (m_strSettingsFile)); }
137
+ catch (...) {}
312
138
313
139
m_etc.m_bPutBackClipboard = CGeneral::getSettingBool (m_settings, " clipboard.putBackAfterPasting" , false );
314
140
m_nClipboardOpenDelay = static_cast <int >(CGeneral::getSettingNumber (m_settings, " clipboard.openDelay" , 0 ));
@@ -375,18 +201,16 @@ void CInit::initialize()
375
201
m_key.m_KeyList .push_back (node);
376
202
}
377
203
m_key.m_defKeySet = COPYPASTE_KEY (m_settings[" keyEvent.default" ]);
378
- m_key.m_nHistoryLimit = m_settings[ " keyEvent.default.copyLimit" ] ;
204
+ m_key.m_nHistoryLimit = static_cast < int >( CGeneral::getSettingNumber ( m_settings, " keyEvent.default.copyLimit" , - 1 )) ;
379
205
380
206
SaveSettings ();
381
207
382
208
// read snippets
383
-
384
209
m_vctMacro.clear ();
385
210
ReadPredefined (m_vctMacro, m_strAppPath + " _locale\\ " + m_locale + " \\ snippets.json" );
386
211
ReadPredefined (m_vctMacro, m_strAppDataPath + " \\ snippets.json" );
387
212
388
213
// read options
389
-
390
214
m_vctDataMacro.clear ();
391
215
ReadPredefined (m_vctDataMacro, m_strAppPath + " _locale\\ " + m_locale + " \\ options.json" );
392
216
}
@@ -498,60 +322,6 @@ void CInit::writeEnvInitData()
498
322
try { std::ofstream (m_strStateFile) << m_state.dump (1 , ' \t ' ) << " \n " ; } catch (...) {}
499
323
}
500
324
501
-
502
- // ---------------------------------------------------
503
- // 関数名 setIniFileInt()
504
- // 機能 設定ファイルを読む
505
- // ---------------------------------------------------
506
- int CInit::setIniFileInt (const TCHAR* szSection,const TCHAR* szKey,int nDefault)
507
- {
508
- int n = (int )::GetPrivateProfileInt (szSection,szKey,-1 ,m_strIniFile);
509
- if (n == -1 ) {
510
- n = nDefault;
511
- writeProfileInt (szSection,szKey,n);
512
- }
513
- return n;
514
- }
515
-
516
- // ---------------------------------------------------
517
- // 関数名 setIniFileString()
518
- // 機能 設定ファイルを読む
519
- // ---------------------------------------------------
520
- CString CInit::setIniFileString (const TCHAR* szSection,const TCHAR* szKey,CString strDefault)
521
- {
522
- TCHAR strBuff[1024 ];
523
- CString strRet;
524
- ::GetPrivateProfileString (szSection,szKey,_T(" " ),strBuff,_countof(strBuff),m_strIniFile);
525
- strRet = strBuff;
526
- if (strRet == " " ) {
527
- // Use default if empty
528
- writeProfileString (szSection,szKey,strDefault);
529
- strRet = strDefault;
530
- }
531
- return strRet;
532
- }
533
-
534
- // ---------------------------------------------------
535
- // 関数名 writeProfileInt()
536
- // 機能 設定ファイルを書き込み
537
- // ---------------------------------------------------
538
- void CInit::writeProfileInt (const TCHAR* szSection,const TCHAR* szKey,int nValue)
539
- {
540
- TCHAR strBuff[1024 ];
541
- _stprintf_s (strBuff,_T (" %d" ),nValue);
542
- WritePrivateProfileString (szSection,szKey,strBuff,m_strIniFile);
543
- }
544
-
545
- // ---------------------------------------------------
546
- // 関数名 writeProfileString()
547
- // 機能 設定ファイルを書き込み
548
- // ---------------------------------------------------
549
- void CInit::writeProfileString (const TCHAR* szSection,const TCHAR* szKey,CString strValue)
550
- {
551
- WritePrivateProfileString (szSection,szKey,_T (" \" " ) + strValue + _T (" \" " ),m_strIniFile);
552
- auto err = GetLastError ();
553
- }
554
-
555
325
// ---------------------------------------------------
556
326
// 関数名 getPasteHotKey
557
327
// 機能 貼り付け系キー設定を取得
0 commit comments