create thread in mfc
1. class member function thread
header
private:
static DWORD TestThread(LPVOID lpParameter);
usage cpp
m_hTestThread = ::CreateThread(NULL,0, (LPTHREAD_START_ROUTINE) MpWatcherWnd::TestThread, (void*)(this), 0, &dwTestThread);
definition cpp
DWORD TestClass::TestThread(LPVOID lpParameter)
{
TestClass* pTest = (TestClass*)lpParameter;
if (pTest)
{
// work
}
else
{
// error!
}
return 0;
}
2. global thread
basic help
http://nsis.sourceforge.net/Main_Page
http://www.kippler.com/doc/nsis/
tutorial
http://nsis.sourceforge.net/Category:Tutorials
sample
http://nsis.sourceforge.net/Category:Code_Examples
http://nsis.sourceforge.net/A_simple_installer_with_start_menu_shortcut_and_uninstaller
download
http://nsis.sourceforge.net/Download
useful links
no?
basic usage
sample.nsi
; sample.nsi
;
; This script is based on example1.nsi, but it remember the directory,
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install Sample.nsi into a directory that the user selects,
;--------------------------------
; define includes
!include "WinMessages.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
; The version of the installer
!define VERSION "1.2.1"
; The name of the installer
Name "Sample ${VERSION}"
; The file to write
OutFile "Sample.${VERSION}.exe"
; The default installation directory
InstallDir "$PROGRAMFILES\Sample"
; define reserved files
ReserveFile "Sample.exe"
ReserveFile "Sample.dll"
ReserveFile "Sample.sys"
ReserveFile "Sample.txt"
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Sample" "C:\Program Files\Sample\"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
; Define Interval variable
Var /GLOBAL DefaultInterval
;--------------------------------
; Pages
; describe license
PageEx license
LicenseData license.txt
PageExEnd
Page components
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; Functions
Function .onInit
FunctionEnd
Function .onInstSuccess
FunctionEnd
Function un.onInit
FunctionEnd
Function un.onUninstSuccess
FunctionEnd
;--------------------------------
; The stuff to install
Section "Sample ${VERSION}"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Sample "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sample" "DisplayName" "Sample"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sample" "Publisher" "Sample Co., Ltd."
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sample" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteUninstaller "uninstall.exe"
; Copy Sample.sys
SetOutPath "C:\WINDOWS\system32\drivers\"
File Sample.sys
; Copy Sample files
;SetOutPath "C:\Program Files\Sample\"
SetOutPath $INSTDIR
File Sample.exe
File Sample.dll
File Sample.txt
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\Sample"
CreateShortCut "$SMPROGRAMS\Sample\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Stop and remove Services
ExecWait '"Cmd.exe" /c net stop Sample'
ExecWait '"Cmd.exe" /c $INSTDIR\Sample.exe -remove'
; Remove registry keys
DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\Sample"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Sample"
DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\Sample"
DeleteRegKey HKLM "Software\Sample"
; Remove files and uninstaller
Delete "$INSTDIR\Sample.nsi"
Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\*.*"
Delete "C:\windows\system32\drivers\Sample.sys"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\Sample\*.*"
; Remove directories used
RMDir "$SMPROGRAMS\Sample"
RMDir "$INSTDIR"
SectionEnd