2020年10月29日 星期四

[c++]程式重啟

void CDlg::ReStart()
{
    // TODO: 在此新增控制元件通知處理程式程式碼
    ::PostMessage(AfxGetMainWnd()->m_hWnd, WM_SYSCOMMAND, SC_CLOSE, NULL);
    //獲取exe程式當前路徑
    TCHAR szAppName[MAX_PATH];
    ::GetModuleFileName(theApp.m_hInstance, szAppName, MAX_PATH);
    CString strAppFullName;
    strAppFullName.Format(_T("%s"), szAppName);
    //重啟程式
    STARTUPINFO StartInfo;
    PROCESS_INFORMATION procStruct;
    memset(&StartInfo, 0sizeof(STARTUPINFO));
    StartInfo.cb = sizeof(STARTUPINFO);
    ::CreateProcess(
        (LPCTSTR)strAppFullName,
        NULL,
        NULL,
        NULL,
        FALSE,
        NORMAL_PRIORITY_CLASS,
        NULL,
        NULL,
        &StartInfo,
        &procStruct);
}



使用方式 : this ->ReStart();

測試環境: MFC 2019

2020年10月13日 星期二

[git]stash指令

 git stash 暫存指令


git stash list 可以看到目前的暫存清單

git stash drop 刪除最近一筆的暫存

git stash clear 刪除所有的暫存

git stash apply 恢復最近一筆

git stash 暫存目前的修正


使用方式:

git status (發現有修正)

git stash

git pull origin

git checkout develop

git status apply


-------


git操作及fatal: Authentication failed for錯誤解決

1、配置使用者資訊

git config –global user.name [username]

git config –global user.email


2、查詢使用者資訊

git config –list

3、如果push遇到在輸入密碼是熟錯後,就會報這個錯誤fatal: Authentication failed for

解決辦法:

git config –system –unset credential.helper

之後你在push就會提示輸入名稱和密碼

在使用此指令 允許權限使用(否則每次都會提示再輸入密碼)

git config --global credential.helper wincred

[GIT]修改commit 合併

 情境::已經commit & push 要再次修改psh上的某一個commit要如何實現

STEP1: git status (確認目前要修改的內容狀態)

STEP2: git add -u (選擇要修改的全部檔案)

STEP3: git commit (因為會合併回上一個commit,在此命名為commit1,commit2)

STEP4: git rebase -i Head~2 (案I,將commit2開頭的pick刪除,改成s,並按下esc,:wq。按I,刪除commit log,再按esc,:wq。)

STEP5: git push origin Head -f

STEP6: 完成瞜! (commit2會合併回commit1)


2020年9月25日 星期五

[C#]建立文件,寫檔,刪除文件

         protected void CreateFile()

        {

            String strTxt = ".\\" TEST.txt";

            String strData = @"123456789";

            // Delete a file by using File class static method...

            if (System.IO.File.Exists(strTxt))

            {

                // Use a try block to catch IOExceptions, to

                // handle the case of the file already being

                // opened by another process.

                try

                {

                    System.IO.File.Delete(strTxt);

                }

                catch (System.IO.IOException e)

                {

                    Console.WriteLine(e.Message);

                    return;

                }

            }

            FileStream fileStream = new FileStream(strTxt, FileMode.Create);


            fileStream.Close();   //切記開了要關,不然會被佔用而無法修改喔!!!


            using (StreamWriter sw = new StreamWriter(strTxt,false))//覆寫檔案

            {

                // 欲寫入的文字資料 ~


                sw.Write(strData );

                //sw.WriteLine(DateTime.Now);

            }


        }

[c#]建創資料夾 取得目前檔案路徑資料夾

         protected void CreateDataTemp()

        {

            string TempPath = System.Windows.Forms.Application.StartupPath + @"\要建立資料夾名稱\";

            if (Directory.Exists(TempPath))

            {

                //資料夾存在

            }

            else

            {

                //新增資料夾

                Directory.CreateDirectory(TempPath);

            }

        }

[C#]Tip提示文字

         

           String strData= @"說明";

            EditBoxInitTip(tb_TEST, strData);


protected void EditBoxInitTip(Control cTB, String strData)

        {

            //ToolTip:當游標停滯在某個控制項時,就會跳出一個小視窗

            ToolTip toolTip1 = new ToolTip();

            //SetToolTip:定義控制項會跳出提示的文字

            toolTip1.SetToolTip(cTB, strData);

            //以下為提示視窗的設定(通常會設定的部分)

            //ToolTipIcon:設定顯示在提示視窗的圖示類型。

            toolTip1.ToolTipIcon = ToolTipIcon.Info;

            //ForeColor:顧名思義就是前景顏色,你懂的!!XD

            toolTip1.ForeColor = Color.Blue;

            //BackColor:顧名思義就是背景顏色,你也懂的!!XD

            toolTip1.BackColor = Color.Gray;

            //AutoPopDelay:當游標停滯在控制項,顯示提示視窗的時間。(以毫秒為單位)

            toolTip1.AutoPopDelay = 1000;

            //ToolTipTitle:設定提示視窗的標題。

            toolTip1.ToolTipTitle = "提示訊息";

        }

2020年6月18日 星期四

[BCB]messagebox


AnsiString str = BoolToStr( o_chkTXT->Checked );
Application->MessageBox(s.c_str(), "Test", 32+3);

 char* c_str()

 AnsiString str = "Hello World!";
  MessageBox(NULL,str.c_str(),"",MB_OK);   //顯示一個消息框

[SQL]顯示千分位與小數顯示

  CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1  (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...