本ページは公開が終了した情報の複製であり、掲載時点での情報です。本ページに記載されている内容について各所に問い合わせることはご遠慮下さい。
サポート技術情報

[VB2] プログラムマネージャ登録時にアイコンを指定する方法(セットアップツールキット)

文書番号: 410501

最終更新日: 1999/03/21


この資料は以下の製品について記述したものです。


この記事は、以前は次の ID で公開されていました: JP410501

概要

Visual Basic for Windows 2.0 に付属のセットアップ ツールキットでは
プログラム マネージャへの登録時にアイコンを指定することができません。
この資料ではプログラム マネージャへ送るコマンド文字列を拡張することで、
アイコンを指定する方法について記述しています。

関連情報

Microsoft(R) Windows(TM) Software Development Kit Version 3.1 プログラマーズ リファレンス Vol.1 概要

サンプル

プロジェクト SETUP1.MAK の中の SETUP1.BAS と SETUP1.FRM に変更を行います。
念のために、これらのファイルのバックアップをとった後に作業を行うことを
お薦めいたします。

CreateProgManItem (SETUP1.BAS)

引数 IconPath$ と IconIndex を追加し、sParam の宣言を追加してください。
また、LinkExecute で送るコマンド文字列を変更してください。
  '----------------------------------------------------------
  ' Procedure: CreateProgManItem
  '
  ' Arguments: X           The form where Label1 exists
  '
  '            CmdLine$    A string that contains the command
  '                        line for the item/icon.
  '                        ie 'c:\myapp\setup.exe'
  '
  '            IconTitle$  A string that contains the item's
  '                        caption
  '
  '
  '            IconPath$   A string that contains the filename
  '                        for the icon to be displayed in the
  '                        group window
  '
  '            IconIndex   Specifies the index of the icon in
  '                        the file indicated by the IconPath$
  '                        parameter
  '                        -1 for default icon
  '
  '----------------------------------------------------------
  Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$, IconPath$, IconIndex)
      Dim sParam As String
      Screen.MousePointer = 11
      '----------------------------------------------------------------------
      ' Windows requires DDE in order to create a program group and item.
      ' Here, a Visual Basic label control is used to generate the DDE messages
      '----------------------------------------------------------------------
      On Error Resume Next
      '---------------------------------
      ' Set LinkTopic to PROGRAM MANAGER
      '---------------------------------
      x.Label1.LinkTopic = "ProgMan|Progman"
      x.Label1.LinkMode = 2
      For i% = 1 To 10     ' Loop to ensure that there is enough time to
        z% = DoEvents()    ' process DDE Execute.  This is redundant but needed
      Next                 ' for debug windows.
      x.Label1.LinkTimeout = 100
      '------------------------------------------------
      ' Create Program Item, one of the icons to launch
      ' an application from Program Manager
      '------------------------------------------------
      '----- original ---------------------------------
      'x.Label1.LinkExecute "[AddItem(" + CmdLine$ + Chr$(44) + IconTitle$ + Chr$(44) + ",,)]"
      '----- original ---------------------------------
      sParam = CmdLine$ + "," + IconTitle$
      sParam = sParam + "," + IconPath$ + ","
      If IconIndex >= 0 Then sParam = sParam + Format$(IconIndex)
      x.Label1.LinkExecute "[AddItem(" + sParam + ")]"
      '-----------------
      ' Reset properties
      '-----------------
      x.Label1.LinkTimeout = 50
      x.Label1.LinkMode = 0
      Screen.MousePointer = 0
  End Sub

Form_Load (SETUP1.FRM)

以下のリストは変更を行う部分のみの抜粋です。CreateProgManItem に引数を
2 つ (destPath$ + "LOAN.EXE" と -1) 追加してください。この例では実行 ファイルを指定していますが、アイコン ファイルを指定することも可能です。
  Sub Form_Load ()
      ... (略) ...
      '--------------------------------------
      ' Create program manager group and icon
      '--------------------------------------
      CreateProgManGroup Setup1, "ローン計算", "LOAN.GRP"
      '----- original -----------------------
      'CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "ローン計算"
      '----- original -----------------------
      CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "ローン計算", destPath$
   + "LOAN.EXE", -1  ' exe's default icon
      'CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "ローン計算",
  destPath$ + "LOAN.ICO", -1 ' icon file.
      ... (略) ...
  End Sub

Keywords: KBHOWTO KB410501
Technology: kbAudDeveloper kbVBSearch

inserted by FC2 system