2010년 7월 29일 목요일

[InstallShield 2008] InstallShield Script







InstallShield Script











 어쩌다 보니 InstallShield를 건들게(?) 되었다. 스크립트가 몬지... 딱 보니 델파이 소스 같기도 하고..


급히 알게된 것들이라.. 또 언제 급하게 하게 될지 몰라 정리해 둔다.








■ 전역 변수





전역 변수를 선언해서 사용할 수 있다.


최 상위에 선언해서 사용하면 된다.





BOOL isStart;







■ 상수 선언





#define MAX_LEN  100


#define NAME        "My Name"









■ if 문





if (condition) then


    // statements to be executed if condition is true


endif;








■ for 문 





for iCount = 1 to 10


        MessageBox ("This appears ten times.", INFORMATION);


endfor;


for iCount = 10 to 100 step 10


        MessageBox ("This appears ten times.", INFORMATION);


endfor;








■ while 문 





nCount = 1;


while (nCount < 5)


    MessageBox ("This is still true.", INFORMATION);


    nCount = nCount + 1;


endwhile;







■ switch 문





STRING szMsg, svResult;


NUMBER nvResult;


GetSystemInfo (VIDEO, nvResult, svResult);


    


switch (nvResult)


    case IS_UNKNOWN: 


        szMsg = "The user's video is unknown.";


    case IS_EGA:


        szMsg = "EGA resolution.";


    case IS_VGA:


        szMsg = "VGA resolution.";


    case IS_SVGA:


        szMsg = "Super VGA (800 x 600) resolution.";


    case IS_XVGA:


        szMsg = "XVGA (1024 x 768) resolution.";


    case IS_UVGA:


        szMsg = "Greater than 1024 x 768 resolution.";


    default:


        szMsg = "Error";


endswitch;









■ 사용자 함수 추가





- prototype 정의


- function body 정의





1. prototype 정의





protype GetPathParts(STRING, BYREF STRING, BYREF STRING, BYREF STRING);





※ 함수 파라미터러 BYVAL 과 BYREF 를 사용한다.


    BYVAL 은 매개변수를 값 타입 으로 넘긴다.


    BYREF 는 매개변수를 참조 타입으로 넘긴다. (C/C++ 의 포인터, 참조 변수라 생각하면 된다.)





2. function body 정의






function GetPathParts(szFullPath, svDrv, svPath, svName)


    LONG lResult;                                                                  // 함수에서 사용할 지역 변수 선언


begin                                                                                  // 함수의 실제 내용 시작


    lResult = ParsePath(svDrv, szFullPath, DISK);


    if (lResult = 0) then


        lResult = ParsePath(svPath, szFullPath, DIRECTORY);


    endif;


    if (lResult = 0) then


        lResult = ParsePath(svName, szFullPath, FILENAME);


    endif;


end;                                                                                    // 함수의 끝









■ C++ DLL 로드





1. 우선 사용할 DLL 을 준비 한다.





2. InstallShield 에서 Support Files/Billboard 탭 선택 후, Language Independent 를 선택한다.


   오른쪽 리스트에 해당 DLL을 추가해 준다.







3. 사용할 함수의 원형을 선언해준다.


   cf) DLL 이름이 parseString 이고 내부 함수가 CalSum 일 경우





prototype cdecl INT parseString.CalSum(BYVAL INT, BYVAL INT);





4. DLL을 로드 한다.





...


STRING szDllPath;


INT nResult;


...





szDllPath = SUPPORTDIR^"parseString.dll";     // DLL 파일 경로 지정


nResult = UseDLL(szDllPath);                        // DLL 로드


if (nResult == 0 ) then                                    // DLL 로드 실패하면 0을 리턴함



    abort;



endif;





nResult = CalSum(1,2);                                 // DLL 에 정의된 함수 사용





UnUseDLL(szDllPath);                                   // 사용한 dll 로드 해제








※ 함수 원형을 선언해 줄 때 cdecl 과 같은 키워드는 dll에 정의된 함수 타입에 따라 달라짐


※ 위 예제를 참조한 블로그 : 외부 dll 함수 호출하여 쓰기




댓글 없음:

댓글 쓰기