'확장자연결'에 해당되는 글 1건

  1. 2013.10.31 인스톨쉴드 스크립트에서 특정 파일 확장자 연결하기
핸디소프트/일일일~2013. 10. 31. 13:34

- win7, win8 에서  클라이언트의 *.htx, *.hwx 파일이 XSviewer.exe 로 열리지 않는 현상이 관찰되어


  인스톨쉴드(버전 X) 스크립트로 해당 확장자에 대해 XSviewer.exe 로 연결시킴


- 설치완료 후엔 레지스트리에 다음과 같이 추가된다

HKEY_CLASSES_ROOT\.htx

HKEY_CLASSES_ROOT\.hwx

HKEY_CLASSES_ROOT\htx.Document

HKEY_CLASSES_ROOT\hwx.Document


- 참고로 아래 부분은 On END 쪽에 넣으면 설치완료후 확인창이 나오지 않기에 OnFirstUIAfter() 쪽에 넣고 메시지박스로 출력하도록 조정


- 위의 OnFirstUIAfter() 쪽에 넣으면 특정 파일들 (dll ) 이 레지스트리에 등록이 되지 않아 OnMoved() 로 변경

 : 참고로 onMoved() 는 설치할 파일이 PC에 복사되고 난 후 실행되는 부분


prototype NUMBER    MakeAssociation(STRING, STRING,STRING);

prototype NUMBER    MakeAssociationEx1(STRING, STRING,STRING);

prototype NUMBER    MakeAssociationEx2(STRING, STRING,STRING);



////////////////////////////////////////////////////////////////////////

//                                                                    //

//  확장자, 확장자 아이콘 등록  함수                                 //

//  Function:   MakeAssociation                                       //

//                                                                    //

//  Purpose:    Creates a file association in the Registry.  Use      //

//            this function for Explorer shell only, as it will       //

//            not create the extra application identification keys,   //

//            which are necessary for Program Mananger shell.         //

//            For Program Manager shell, you can use the script-      //

//            based function MakeAssociationEx.                       //

//                                                                    //

//  Parameters:                                                       //

//      szApp:    String with full path to the executable to be       //

//                associated with the file extension.                 //

//                                                                    //

//      szExtension:  String with the extension to be associated      //

//                with an application.  Must include the preceding    //

//                period (for example:  ".txt")                       //

//                                                                    //

//      szIcon :   String with full path to the executable to be      //

//                associated with the file Icon                       //

//                                                                    //

//                                                                    //

////////////////////////////////////////////////////////////////////////


  

function MakeAssociation(szApp, szExtension, szIcon)

BOOL      bResult;

NUMBER    nResult;

STRING szOpen;

begin

  RegDBSetDefaultRoot ( HKEY_CLASSES_ROOT );

  //bResult = RegDBKeyExist(szExtension);

  //if (bResult = TRUE) then

//    nResult = AskYesNo ("Warning the extension " + szExtension + " is already registered. Overwrite?", YES);

//    if (nResult = NO) then

//       return -1;

//    endif;

//  endif;

  LongPathToShortPath (szApp);

  szApp = szApp + " \"%1\"";

  szOpen = "open" + " \"%1\""; 

  RegDBCreateKeyEx (szExtension, "");

  

  RegDBCreateKeyEx (szExtension + "\\DefaultIcon", "");

  RegDBSetKeyValueEx (szExtension + "\\DefaultIcon","", REGDB_STRING, szIcon, -1);

  RegDBCreateKeyEx (szExtension + "\\shell", "");

  RegDBCreateKeyEx (szExtension + "\\shell\\open", "");

  RegDBCreateKeyEx (szExtension + "\\shell\\open\\command", "");

  RegDBSetKeyValueEx (szExtension + "\\shell\\open\\command", "", REGDB_STRING, szApp, -1);

  

  //RegDBCreateKeyEx (szExtension + "\\shell\\open\\ddeexec", "");//추가

  //RegDBSetKeyValueEx (szExtension + "\\shell\\open\\ddeexec", "", REGDB_STRING, szOpen, -1);//추가

  

  return 0;

end;


////////////////////////////////////////////////////////////////////////  


function MakeAssociationEx1(szApp, szExtension, szName)

BOOL      bResult;

NUMBER    nResult;

STRING    svKeyName;


begin

  RegDBSetDefaultRoot ( HKEY_CLASSES_ROOT );


  StrSub ( svKeyName , szExtension , 1 , 3 );

  svKeyName = svKeyName + ".Document";


//  bResult = RegDBKeyExist(szExtension);

//  if (bResult = TRUE) then

//    nResult = AskYesNo ("Warning the extension " + szExtension + " is already registered. Overwrite?", YES);

//    if (nResult = NO) then

//       return -1;

//    endif;

//  endif;


  LongPathToShortPath (szApp);

  szApp = szApp + " \"%1\"";

  RegDBCreateKeyEx (szExtension, "");

  RegDBSetKeyValueEx ( szExtension , "" , REGDB_STRING , svKeyName , -1 );


  RegDBCreateKeyEx (svKeyName, "");

  RegDBSetKeyValueEx ( svKeyName , "" , REGDB_STRING , szName , -1 );

  RegDBCreateKeyEx (svKeyName + "\\shell", "");

  RegDBCreateKeyEx (svKeyName + "\\shell\\open", ""); 

  RegDBCreateKeyEx (svKeyName + "\\shell\\print", ""); 

  RegDBCreateKeyEx (svKeyName + "\\shell\\open\\command", "");

  //RegDBCreateKeyEx (svKeyName + "\\shell\\print\\command", "");

  RegDBSetKeyValueEx (svKeyName + "\\shell\\open\\command", "", REGDB_STRING, szApp, -1);

  //RegDBSetKeyValueEx (svKeyName + "\\shell\\print\\command", "", REGDB_STRING, szApp, -1);


  return 0;

end;  //End of function MakeAssociationEx


////////////////////////////////////////////////////////////////////////


function MakeAssociationEx2(szApp, szExtension, szName)

BOOL      bResult;

NUMBER    nResult;

STRING    svKeyName;


begin

  RegDBSetDefaultRoot ( HKEY_CLASSES_ROOT );


  StrSub ( svKeyName , szExtension , 1 , 3 );

  svKeyName = svKeyName + ".Document";


//  bResult = RegDBKeyExist(szExtension);

//  if (bResult = TRUE) then

//    nResult = AskYesNo ("Warning the extension " + szExtension + " is already registered. Overwrite?", YES);

//    if (nResult = NO) then

//       return -1;

//    endif;

//  endif;


  LongPathToShortPath (szApp);

  szApp = szApp + " \"%1\"";

  RegDBCreateKeyEx (szExtension, "");

  RegDBSetKeyValueEx ( szExtension , "" , REGDB_STRING , svKeyName , -1 );


  RegDBCreateKeyEx (svKeyName, "");

  RegDBSetKeyValueEx ( svKeyName , "" , REGDB_STRING , szName , -1 );

  RegDBCreateKeyEx (svKeyName + "\\shell", "");

  RegDBCreateKeyEx (svKeyName + "\\shell\\open", ""); 

  RegDBCreateKeyEx (svKeyName + "\\shell\\print", ""); 

  //RegDBCreateKeyEx (svKeyName + "\\shell\\open\\command", "");

  RegDBCreateKeyEx (svKeyName + "\\shell\\print\\command", "");

  //RegDBSetKeyValueEx (svKeyName + "\\shell\\open\\command", "", REGDB_STRING, szApp, -1);

  RegDBSetKeyValueEx (svKeyName + "\\shell\\print\\command", "", REGDB_STRING, szApp, -1);


  return 0;

end;  //End of function MakeAssociationEx2


///////////////////////////////////////////////////////////////////////////////


function OnMoved()

begin         

MakeAssociation(TARGETDIR ^ "\\bin" ^ "XSViewer.exe", ".htx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

MakeAssociation(TARGETDIR ^ "\\bin" ^ "XSViewer.exe", ".hwx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

MakeAssociationEx1(TARGETDIR ^ "\\bin" ^ "XSViewer.exe", ".htx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

MakeAssociationEx1(TARGETDIR ^ "\\bin" ^ "XSViewer.exe", ".hwx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

MakeAssociationEx2(TARGETDIR ^ "\\bin" ^ "XSViewer.exe /p", ".htx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

MakeAssociationEx2(TARGETDIR ^ "\\bin" ^ "XSViewer.exe /p", ".hwx",TARGETDIR ^ "\\bin" ^ "XSViewer.exe,0" );

//MessageBox ("HANDY Groupware 클라이언트가 설치 완료 되었습니다.", INFORMATION);


end;



Posted by 배터리