Download Print this page

STC micro STC8A8K64D4 Series Reference Manual page 873

Advertisement

STC8A8K64D4 Series Manual
const UINT ID_PROGRESS
// Full path of publishing project program
path = _T("D:\\Work\\Upgrade.exe");
// variable initialization
memset(&si, 0, sizeof(STARTUPINFO));
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
memset(&cp, 0, sizeof(CALLBACK_PARAM));
// Set startup variables
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.wShowWindow = SW_SHOWNORMAL;
publishing the project program will not be displayed, and all ISP operations can be performed in the background
si.dwFlags = STARTF_USESHOWWINDOW;
// Create a process for publishing a project program
if (CreateProcess(NULL, (LPTSTR)(LPCTSTR)path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
// Wait for the release project program process initialization to complete
WaitForInputIdle(pi.hProcess, 5000);
// Get the main window handle of the publishing project program
cp.dwProcessId = pi.dwProcessId;
cp.hMainWnd = NULL;
EnumWindows(EnumWindowCallBack, (LPARAM)&cp);
if (cp.hMainWnd != NULL)
{
HWND hProgram;
HWND hStop;
HWND hPort;
// Get the handle of some controls in the main window of the publishing project program
hProgram = ::GetDlgItem(cp.hMainWnd, ID_PROGRAM);
hStop = ::GetDlgItem(cp.hMainWnd, ID_STOP);
hPort = ::GetDlgItem(cp.hMainWnd, ID_COMPORT);
// Set the serial port number in the release project program, the third parameter is 0:COM1, 1:COM2, 2:COM3, ...
::SendMessage(hPort, CB_SETCURSEL, 0, 0);
// Trigger the programming button to start ISP programming
::SendMessage(hProgram, BM_CLICK, 0, 0);
// wait for programming to complete,
// Since the main process will be blocked here, it is recommended to create a new working process and wait in the
worker process
while (!::IsWindowEnabled(hProgram));
// Close the release project program after programming is complete
::SendMessage(cp.hMainWnd, WM_CLOSE, 0, 0);
}
// wait for the process to end
WaitForSingleObject(pi.hProcess,INFINITE);
= 1044;
// If it is set to SW_HIDE here, the operation interface for
- 857 -

Advertisement

loading
Need help?

Need help?

Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Micro stc8a8k64d4-64pinMicro stc8a8k64d4-48pin