Install Sofware Packaged

Untuk Mempermudah proses instalasi aplikasi sample maupun aplikasi yg sesungguhnya maka di gunakan proses instalasi secara mudah dan ini screen shoot :

This is coding

/*
* MINIGUI – Harbour Win32 GUI library Demo
*
* Copyright 2002-2005 Roberto Lopez
* http://harbourminigui.googlepages.com/
*
* Copyright 2004-2006 Grigory Filatov
*
* July 2005 Additions as noted by Joe Fanucchi
*
* FOR PROGRAMMING:
* Changed the grammar of window titles and of some instructions
* Renamed most controls (so I can keep them clear in my head)
* Put all the control visibility statements in ShowStep() and HideStep() functions, to minimize repetitive code
*
* FOR THE USER:
* Changed the size of the Form_2 window, and the size and position of RichEdit boxes, frames, and buttons
* Added the ability to specify an icon to be used for the Desktop and Start Menu links
* Added the ability for the user to confirm creation of a new destination folder
* Added a RichEdit box to notify the user of installation success/failure
*/
*———————————————————————————-*

#include “minigui.ch”
#include “fileio.ch”

#define MsgYesNo( c, t ) MsgYesNo( c, t, .F., , .F. )
#define MsgNoYes( c ) MsgYesNo( c, “Confirming…”, .T., , .F. )
#define MsgAlert( c ) MsgExclamation( c, “Error !”, , .F. )

#define EWX_REBOOT 2

#define WM_CLOSE 0x0010

DECLARE WINDOW Form_1
DECLARE WINDOW Form_2

*————————————————————*
PROCEDURE Main
*————————————————————*
LOCAL x := GetDesktopWidth()
LOCAL y := GetDesktopHeight()

LOCAL cPath := GetStartUpFolder() + “\”
LOCAL cFileName := cFileNoExt( GetExeFileName() )
LOCAL cCfgFile := cPath + Lower( cFileName ) + “.ini”

* JF: made some small changes to the grammar, not a significant change:
LOCAL cMsg := “Do you wish to cancel this installation?”

LOCAL aLink := {}
LOCAL cWhat2Link2 := “”
* JF: added the ability to specify an icon for the Desktop and Start Menu links
LOCAL cIconName := ”
LOCAL cImgExt := “bmp”
* JF: changed the default install folder to “C:\Program Files\” + cProgramName
LOCAL cDestinPath
LOCAL cLinkName := “”
LOCAL cOnDesktop := “0”
LOCAL cProgramName := “”
LOCAL cSMenuFolder := “”
LOCAL cTmpFld := “”
LOCAL i
LOCAL lChange := .F.
LOCAL lExit := .F.
LOCAL lNeedReboot := .F.
LOCAL lNoLinks := .F.
LOCAL lOnDesktop := .F.
LOCAL lStartMenu := .F.

*————————————————————*

BEGIN INI FILE cCfgFile

GET cDestinPath SECTION “General” ENTRY “InstallPath” DEFAULT cDestinPath
GET cProgramName SECTION “General” ENTRY “ProgramName” DEFAULT cProgramName
* JF: added the ability to specify an icon for the Desktop and Start Menu links
GET cIconName SECTION “General” ENTRY “IconName” DEFAULT cIconName
GET lNeedReboot SECTION “General” ENTRY “NeedReboot” DEFAULT lNeedReboot

FOR i := 1 TO 99
GET cLinkName SECTION “Links” ENTRY “LinkName” + LTRIM( STR( i )) DEFAULT “”
GET cWhat2Link2 SECTION “Links” ENTRY “FileName” + LTRIM( STR( i )) DEFAULT “”
GET cOnDesktop SECTION “Links” ENTRY “OnDesktop” + LTRIM( STR( i )) DEFAULT cOnDesktop
IF EMPTY( cLinkName)
EXIT
ELSE
Aadd( aLink, { cLinkName, cWhat2Link2, VAL( cOnDesktop ) })
ENDIF
NEXT

GET cSMenuFolder SECTION “Folder” ENTRY “StartMenuFolder” DEFAULT cSMenuFolder

END INI

*————————————————————*

IF FileSize( cCfgFile ) == 0
BEGIN INI FILE cCfgFile

* JF: changed the default install path to “C:\Program Files\” + cProgramName
SET SECTION “General” ENTRY “InstallPath” TO cDestinPath
SET SECTION “General” ENTRY “ProgramName” TO cProgramName
SET SECTION “General” ENTRY “NeedReboot” TO lNeedReboot
* JF: added the ability to specify an icon for the Desktop and Start Menu links
SET SECTION “General” ENTRY “IconName” TO cIconName

FOR i := 1 TO LEN( aLink )
SET SECTION “Links” ENTRY “LinkName” + LTRIM( STR( i )) TO aLink[i][1]
SET SECTION “Links” ENTRY “FileName” + LTRIM( STR( i )) TO aLink[i][2]
SET SECTION “Links” ENTRY “OnDesktop” + LTRIM( STR( i )) TO STR( aLink[i][3], 1)
NEXT

SET SECTION “Folder” ENTRY “StartMenuFolder” TO cSMenuFolder

END INI
ENDIF

* JF: Added this variable so the expression is only checked once
IF EMPTY( LEN( aLink ))
lNoLinks := .T.
ELSE
lOnDesktop := ASCAN( aLink, { |e| e[3] == 1 } ) > 0
lStartMenu := ( ASCAN( aLink, { |e| e[3] == 0 } ) > 0 ) .AND. ! EMPTY( cSMenuFolder )
ENDIF

*————————————————————*

* JF: changed the default install path to “C:\Program Files\” + cProgramName
IF EMPTY( cDestinPath ) // JF: If the installation path isn’t in the SETUP.INI file, create it here
cDestinPath := GetProgramFilesFolder() + “\” + cProgramName
ENDIF

IF x <= 1024 .AND. y ‘ ;
ACTION ( HideStep1(), ShowStep2( cProgramName )) ;
WIDTH 78 ;
HEIGHT 26

@ Form_2.Height – 69, 390 BUTTON Btn_Cancel ; // JF: this was Btn_2
CAPTION ‘&Cancel’ ;
ACTION ( Form_2.Release ) ;
WIDTH 78 ;
HEIGHT 26

@ Form_2.Height – 69, 190 BUTTON Btn_Back2Intro ; // JF: this was Btn_3
CAPTION ” ) ;
; // JF: if there are no links to be created, proceed to install
ACTION IIF( lNoLinks, ;
; // JF: changed Install() function as described below
Install( cPath, cDestinPath, aLink, lOnDesktop, lStartMenu, cSMenuFolder, ;
cProgramName, cIconName, @lNeedReboot ), ;
;
( HideStep2(), ShowStep3( cProgramName, lOnDeskTop, lStartMenu, lChange ))) ;
WIDTH 78 ;
HEIGHT 26

@ Form_2.Height – 69, 190 BUTTON Btn_Back2Step2 ; // JF: this was Btn_5
CAPTION ‘ 2, cExeName, cIcon) ) # 0
* JF: changed MsgStop() to MsgExclamation(), since the installation of the program was completed
MsgAlert( “Setup was unable to create the Start Menu Link” )
ENDIF
ENDIF
NEXT
ENDIF
Go2Finish( cProgramName, lNeedReboot ) // JF: Inform the user that installation was successful
ELSE
* JF: Don’t reboot if the installation was unsuccessful
lNeedReboot := .F.
* JF: Inform the user that SETUP.ZIP could not be found, and exit Setup
BailOut( cProgramName )
ENDIF

RETURN NIL
*
*————————————————————*
STATIC FUNCTION Go2Finish( cProgramName, lNeedReboot )
*————————————————————*
* JF: Install() can be called from Step 2 or Step 3, so hide both sets of controls
HideStep2()
HideStep3()

* JF: Inform the user that installation was successful
Form_2.Title := ” ” + cProgramName + ” Setup Completed !”
Form_2.Edit_Success.Visible := .T.

* JF: Display the “Reboot” options if required
Form_2.Frame_Reboot.Visible := lNeedReboot
Form_2.Radio_Reboot.Visible := lNeedReboot

* JF: Display only the “Finish” button
Form_2.Btn_Cancel.Visible := .F.
Form_2.Btn_Finish.Visible := .T.
Form_2.Btn_Finish.SetFocus

RETURN NIL
*
*————————————————————*
STATIC FUNCTION BailOut( cProgramName )
*————————————————————*
* JF: Installation was unsuccessful because SETUP.ZIP was not found
* JF: Install() can be called from Step 2 or Step 3, so hide both sets of controls
HideStep2()
HideStep3()

* JF: Inform the user that installation was unsuccessful
Form_2.Title := ” ” + cProgramName + ” Setup Cancelled !”
Form_2.Edit_Failure.Visible := .T.

* JF: Display only the “Finish” button
Form_2.Btn_Cancel.Visible := .F.
Form_2.Btn_Finish.Caption := “E&xit”
Form_2.Btn_Finish.Visible := .T.
Form_2.Btn_Finish.SetFocus

RETURN NIL
*
*——————————————————–*
FUNCTION IsZipFile( cFilename )
*——————————————————–*
LOCAL nHandle, cBuffer := Space(4)

IF ( nHandle := FOPEN( cFilename, FO_READ + FO_SHARED ) ) -1

FSEEK( nHandle, 0, FS_SET ) // go to top of file

IF FREAD( nHandle, @cBuffer, 4 ) == 4

IF Left( cBuffer, 1 ) == ‘P’ .AND. Substr( cBuffer, 2, 1 ) == ‘K’ .AND. ;
Substr( cBuffer, 3, 1 ) == Chr(3) .AND. Right( cBuffer, 1 ) == Chr(4)
FCLOSE( nHandle ) // close file
RETURN .T.
ENDIF
ENDIF

FCLOSE( nHandle ) // close file

ENDIF

RETURN .F.
*
*————————————————————*
PROCEDURE ExitWindows( nFlag )
*————————————————————*
IF IsWinNT()
EnablePermissions()
ENDIF

IF ExitWindowsEx( nFlag, 0 )
Form_2.Release
ENDIF

RETURN
*
#pragma BEGINDUMP

#include
#include
#include “hbapi.h”
#include “hbvm.h”
#include “hbstack.h”
#include “hbapiitm.h”
#include “winreg.h”
#include “tchar.h”

#include

void ChangePIF(LPCSTR cPIF);
HRESULT WINAPI CreateLink(LPSTR lpszLink, LPSTR lpszPathObj, LPSTR lpszWorkPath, LPSTR lpszIco, int nIco);

BOOL DirectoryExists( LPTSTR szDirName )
{
unsigned int nAttributes;
if ( ( nAttributes = GetFileAttributes( szDirName ) ) == -1 ) return FALSE;
if ( ( nAttributes & FILE_ATTRIBUTE_DIRECTORY ) != 0 ) return TRUE;
return FALSE;
}

HB_FUNC( CREATEFILELINK )
{
hb_retnl( (LONG) CreateLink( (char *) hb_parc(1), (char *) hb_parc(2), (char *) hb_parc(3), (char *) hb_parc(4),
(hb_pcount()>4)? hb_parni(5) : 0 )) ;
}

/***************************************************************************\
* *
* Autor: Jose F. Gimenez (JFG) *
* *
* *
* Fecha: 2000.10.02 *
* *
\***************************************************************************/

void ChangePIF(LPCSTR cPIF)
{
UCHAR buffer[1024];
HFILE h;
long filesize;

strcpy(buffer, cPIF);
strcat(buffer, “.pif”);
if ((h=_lopen(buffer, 2))>0)
{
filesize=_hread(h, &buffer, 1024);
buffer[0x63]=0x10; // Cerrar al salir
buffer[0x1ad]=0x0a; // Pantalla completa
buffer[0x2d4]=0x01;
buffer[0x2c5]=0x22; // No Permitir protector de pantalla
buffer[0x1ae]=0x11; // Quitar ALT+ENTRAR
buffer[0x2e0]=0x01;
_llseek(h, 0, 0);
_hwrite(h, buffer, filesize);
_lclose(h);
}
}

HRESULT WINAPI CreateLink(LPSTR lpszLink, LPSTR lpszPathObj, LPSTR lpszWorkPath, LPSTR lpszIco, int nIco)
{
long hres;
IShellLink * psl;

hres = CoInitialize(NULL);
if (SUCCEEDED(hres))
{
hres = CoCreateInstance(&CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, &IID_IShellLink, ( LPVOID ) &psl);

if (SUCCEEDED(hres))
{

IPersistFile * ppf;

psl->lpVtbl->SetPath(psl, lpszPathObj);
psl->lpVtbl->SetIconLocation(psl, lpszIco, nIco);
psl->lpVtbl->SetWorkingDirectory(psl, lpszWorkPath);

hres = psl->lpVtbl->QueryInterface(psl,
&IID_IPersistFile,
( LPVOID ) &ppf);

if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
char cPath[MAX_PATH];

strcpy(cPath, lpszLink);
strcat(cPath, “.lnk”);

MultiByteToWideChar(CP_ACP, 0, cPath, -1, wsz, MAX_PATH);

hres = ppf->lpVtbl->Save(ppf, wsz, TRUE);
ppf->lpVtbl->Release(ppf);

// modificar el PIF para los programas MS-DOS
ChangePIF(lpszLink);

}
psl->lpVtbl->Release(psl);
}
CoUninitialize();
}
return hres;
}

/***************************************************************************/

HB_FUNC( FILLBLUE )
{
HWND hwnd;
HBRUSH brush;
RECT rect;
HDC hdc;
int cx;
int cy;
int blue = 200;
int steps;
int i;

hwnd = (HWND) hb_parnl( 1 );
hdc = GetDC( hwnd );

GetClientRect( hwnd, &rect );

cx = rect.top;
cy = rect.bottom;
steps = (cy – cx) / 4;
rect.bottom = 0;

for( i = 0 ; i < steps ; i++ )
{
rect.bottom += 4;
brush = CreateSolidBrush( RGB( 0, 0, blue ));
FillRect( hdc, &rect, brush );
DeleteObject( brush );
rect.top += 4;
blue -= 1;
}

ReleaseDC( hwnd, hdc );
}

HB_FUNC( ENABLEPERMISSIONS )

{
LUID tmpLuid;
TOKEN_PRIVILEGES tkp, tkpNewButIgnored;
DWORD lBufferNeeded;
HANDLE hdlTokenHandle;
HANDLE hdlProcessHandle = GetCurrentProcess();

OpenProcessToken(hdlProcessHandle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hdlTokenHandle);

LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &tmpLuid);

tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = tmpLuid;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

AdjustTokenPrivileges(hdlTokenHandle, FALSE, &tkp, sizeof(tkpNewButIgnored), &tkpNewButIgnored, &lBufferNeeded);
}

HB_FUNC( EXITWINDOWSEX )

{
hb_retl( ExitWindowsEx( (UINT) hb_parni( 1 ), (DWORD) hb_parnl( 2 )) );
}

HB_FUNC( ISDIRECTORY )
{
hb_retl( DirectoryExists( (char *) hb_parc(1) ) ) ;
}

#pragma ENDDUMP

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: