顯示具有 開檔 標籤的文章。 顯示所有文章
顯示具有 開檔 標籤的文章。 顯示所有文章

2023年3月24日 星期五

[C#]開啟外部程式方式

除了用以下方式:
https://rexyuan0502.blogspot.com/2019/01/c_11.html

也可以使用下列方式執行:

using System.Diagnostics;
using System.ComponentModel;

 class MyProcess
    {
        public string g_StrFullPath = "C:\\Test\\NSServer.exe";
        public string g_StrPath = "C:\\Test";
        public string g_StrName = "NSServer.exe";
        // Opens the Internet Explorer application.
        void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start(g_StrFullPath);

            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);
        }

        // Opens urls and .html documents using Internet Explorer.
        void OpenWithArguments()
        {
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start(g_StrFullPath, g_StrPath);

            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start(g_StrFullPath, g_StrPath);
            Process.Start(g_StrFullPath, g_StrPath);
        }

        // Uses the ProcessStartInfo class to start new processes,
        // both in a minimized mode.
        void OpenWithStartInfo()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(g_StrFullPath);
            startInfo.WindowStyle = ProcessWindowStyle.Normal;

            Process.Start(startInfo);

            startInfo.Arguments = g_StrPath;

            Process.Start(startInfo);
        }

        public void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            //myProcess.OpenApplication(myFavoritesPath);
            //myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();
        }
    }


使用方式 可放到namespace 中 拆解使用

2019年5月20日 星期一

[c++]開檔讀檔寫檔fopen() fwrite()

//在mfc中使用前請先至Stdafx.h 宣告定義
#define _CRT_SECURE_NO_WARNINGS




---------以下為範例--------------------------

FILE *pFile;
char cbuffer[] = { 'h','e','l' ,'l' ,'o' };
pFile = fopen("hello.txt""w");
if (pFile == NULL)
{
 MessageBox(L"empty");
}
else
{
 fwrite(cbuffer,1, sizeof(cbuffer), pFile);
}
fclose(pFile);


測試環境:2015--mfc



參考以下:
FILE * fopen ( const char * filename, const char * mode );
1    

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

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