Winx.h

[目次 | 型・クラス・構造体 | マクロ]

目次

型・クラス・構造体一覧

マクロ一覧


   1|/**************************************************************************
   2|   1. <<< Windows API (WinX) >>> 
   3|***************************************************************************/
   4|
   5|#ifndef __WINX_H
   6|#define __WINX_H
   7|
   8|#ifndef USES_PRIORITY_HEADER
   9|/*[START_OF_PRIORITY_HEADER]*/
  10|
  11|#ifndef  USES_WINX
  12|#define  USES_WINX
  13|
  14|typedef  struct _WinX_RegData  WinX_RegData;
  15|typedef  struct _WinX_RegData  WinX_RegData;
  16|
  17|typedef  struct _WinX_DdeAct  WinX_DdeAct;
  18|typedef  struct _WinX_FType   WinX_FType;
  19|typedef  struct _WinX_Autorun WinX_Autorun;
  20|
  21|typedef  struct _WinX_Inst      WinX_Inst;
  22|typedef  struct _WinX_InstType  WinX_InstType;
  23|typedef  struct _WinX_InstCmd   WinX_InstCmd;
  24|typedef  struct _WinX_Uninst    WinX_Uninst;
  25|typedef  enum   _WinX_DefType   WinX_DefType;
  26|
  27|#endif
  28|
  29|#define  STDLIBS_INCLUDE_STDLIB_H
  30|
  31|/*[END_OF_PRIORITY_HEADER]*/
  32|#endif /* USES_PRIORITY_HEADER */
  33|
  34|
  35|#define  WinX_Err_API_Error  991
  36|#define  WinX_Err_NoRegKey   992
  37|#define  WinX_Err_NotMatchActionName  993
  38|#define  WinX_Err_NoRegData  994
  39|#define  WinX_Err_DifferentType  995
  40|#define  WinX_Err_TooLongPath    996
  41|#define  WinX_Err_CannotAddNest  997
  42|#define  WinX_Err_AccessDenied   998
  43|#define  WinX_Err_FileNotFound   999
  44| 
  45|/*------------------------------------------------------------------------*/
  46|/* 2. <<< Interface Area ----------------------------------------------- >>> */ 
  47|/*------------------------------------------------------------------------*/
  48|
  49|#ifdef __cplusplus
  50|extern "C" {
  51|#endif
  52|
  53| 
  54|/**************************************************************************
  55|  3. <<< サブルーチン >>> 
  56|***************************************************************************/
  57|typedef  const unsigned char*  WinX_DataPtr;  // レジストリの値の型
  58|
  59|void   WinX_error(void);
  60|#ifdef _WINDOWS_
  61| void   WinX_error2( LONG code );
  62|#endif
  63|
  64|void  WinX_throw( int errcode );
  65|void  WinX_throwDde( unsigned long dde );
  66|
  67|/* 内部用 */
  68|void  WinX_throw_imp( int errcode, char* file, int line );
  69|void  WinX_throwDde_imp( unsigned long dde, char* file, int line );
  70| 
  71|/**************************************************************************
  72|  4. <<< レジストリ関係 >>> 
  73|***************************************************************************/
  74|
  75|#ifdef _WINREG_
  76|  void  WinX_getReg( HKEY baseKey, const char* subKeyPath, bool bDef, WinX_RegData* data );
  77|  void  WinX_setReg( HKEY baseKey, const char* subKeyPath, bool bDef, WinX_RegData* data );
  78|  void  WinX_delReg( HKEY baseKey, const char* subKeyPath, bool bKey );
  79|  void  WinX_delRegIfNoSub( HKEY baseKey, const char* path );
  80|  bool  WinX_isExistReg( HKEY baseKey, const char* path, bool bKey, bool bKeyOrData );
  81|
  82|  char*  WinX_getReg_s( HKEY baseKey, const char* subKeyPath,
  83|    const char* name, char* var, int var_size );
  84|  char*  WinX_getReg_x( HKEY baseKey, const char* subKeyPath,
  85|    const char* name, void* var, int var_size );
  86|
  87|  void  WinX_copyRegNest( HKEY dstKey, const char* dstPath,
  88|    HKEY srcKey, const char* srcPath );
  89|  void  WinX_delRegNest( HKEY baseKey, const char* path );
  90|#endif
  91|
  92| 
  93|/**************************************************************************
  94|  5. <<< (WinX_RegData) レジストリ・データ >>> 
  95|【補足】
  96|・WinX_RegData_init でデータ領域を設定してから使うことができます。
  97|・WinX_getRegWinX_setReg などで使われます。
  98|・レジストリのデータの型は次のとおりです。(MSDNヘルプより抜粋)
  99|  値                意味
 100| *REG_BINARY        任意の形式のバイナリデータです。
 101| *REG_DWORD         32 ビット値です。
 102|  REG_DWORD_LITTLE_ENDIAN  リトルエンディアン形式の 32 ビット値です。REG_DWORD と同じです。Windows NT と Windows 95 が動作するコンピュータにおいて、もっとも一般的な形式です。
 103|  REG_DWORD_BIG_ENDIAN     ビッグエンディアン形式の 32 ビット値です。
 104|  REG_EXPAND_SZ     展開前の環境変数への参照 (たとえば“%PATH%”) が入った NULL で終わる文字列です。Unicode 関数と ANSI 関数のどちらを使用しているかにより、Unicode 文字列または ANSI 文字列になります。
 105|  REG_LINK          Unicode のシンボリックリンクです。
 106|  REG_MULTI_SZ      NULL で終わる文字列の配列です。連続する 2 つの NULL 文字で、終端を示します。
 107|  REG_NONE          定義されていない種類です。
 108|  REG_RESOURCE_LIST デバイスドライバのリソースリストです。
 109| *REG_SZ            NULL で終わる文字列です。Unicode 関数と ANSI 関数のどちらを使用しているかにより、Unicode 文字列または ANSI 文字列になります。
 110|***************************************************************************/
 111|#ifdef _WINREG_
 112|  WinX_RegData_init( WinX_RegData*, void* data, int data_size );
 113|
 114|  struct _WinX_RegData {
 115|    DWORD  type;     /* データ型(→補足) */
 116|    char*  data;     /* データの格納領域の先頭アドレス */
 117|    DWORD  size;     /* 格納されているデータのサイズ(byte) */
 118|    DWORD  maxSize;  /* データの格納領域のサイズ(byte) */
 119|  };
 120|#endif
 121| 
 122|/**************************************************************************
 123|  6. <<< [WinX_RegNest] サブ・レジストリを含めてレジストリデータを列挙する >>> 
 124|【補足】
 125|・親は、データは無くキーのみです。データは、キーの集まりの後に集まっています。
 126|・1つのキーのサブキーは、逆順で格納されます。
 127|***************************************************************************/
 128|#define  WinX_nestM  50
 129|#define  WinX_absPathSize  255
 130|#define  WinX_RegNest_bufM  8192
 131|#define  WinX_RegNest_nameSize  250
 132|
 133|typedef  struct _WinX_RegNest  WinX_RegNest;
 134|
 135|void  WinX_RegNest_init( WinX_RegNest*, HKEY baseKey, const char* absPath,
 136|  bool bFinishedDir );
 137|void  WinX_RegNest_finish( WinX_RegNest* );
 138|bool  WinX_RegNest_next( WinX_RegNest* );
 139|
 140|char*  WinX_RegNest_getName( WinX_RegNest* );
 141|char*  WinX_RegNest_getStepPath( WinX_RegNest* );
 142|char*  WinX_RegNest_getAbsPath( WinX_RegNest* );
 143|int    WinX_RegNest_getNumer( WinX_RegNest* );
 144|int    WinX_RegNest_getDenomi( WinX_RegNest* );
 145|bool   WinX_RegNest_getIsKey( WinX_RegNest* );
 146|
 147|void  WinX_RegNest_getData( WinX_RegNest*, WinX_RegData* data );
 148|int   WinX_RegNest_getDataCount( WinX_RegNest* );
 149|int   WinX_RegNest_getNotExpandSubKeyCount( WinX_RegNest* );
 150|
 151|
 152|struct _WinX_RegNest {
 153|  char** fname; /* キー名かデータ名のポインタ配列, WinX_RegNest_bufM * WinX_RegNest_nameSize */
 154|  char*  fname_memArea;
 155|
 156|  bool  bFinishedDir;  /* 探索が済んだディレクトリも列挙するかどうか */
 157|
 158|  int*  I;  /* 最後の配列要素はデータへのポインタ、*/
 159|            /* その1つ前の配列要素は、次のサブキー */
 160|            /* それ以外の配列要素は、*/
 161|            /* 列挙し終わった各段の最後のサブキーへのポインタ */
 162|  int   nest;  /* ネスト・レベル、0 が基底 */
 163|
 164|  bool  bKey;  /* 最後の配列要素キーかどうか(キーでないならデータ)*/
 165|
 166|  HKEY  baseKey; /* 基底キー */
 167|  char  absPath[WinX_absPathSize+1]; /* 基底ディレクトリ・パス */
 168|  char  workPath[WinX_absPathSize+1]; /* 出力用 */
 169|};
 170| 
 171|/**************************************************************************
 172|  7. <<< パス関係 >>> 
 173|***************************************************************************/
 174|char*  WinX_getWSHPath(void);
 175|char*  WinX_getWindowsPath(void);
 176|char*  WinX_getSystemPath(void);
 177|char*  WinX_getDesktopPath(void);
 178|char*  WinX_getProgramPath(void);
 179|char*  WinX_getSendToPath(void);
 180|char*  WinX_getMyDocPath(void);
 181|char*  WinX_getTempPath(void);
 182|void   WinX_getShortCutTarget( const char* shortCut_path, char* target_path );
 183|void  WinX_createShortcut( const char* path, const char* targetPath,
 184|  const char* param, const char* workPath, int showFlags,
 185|  const char* iconPath, int iIcon, const char* description );
 186|bool  WinX_openFolderSelDlg( HWND parent, const char* title, char* path );
 187| 
 188|/**************************************************************************
 189|  8. <<< ディスプレイ関係 >>> 
 190|***************************************************************************/
 191|int    WinX_getDisplayBpp(void);
 192|void   WinX_setDisplayBppReturnValue( int bpp );
 193|
 194| 
 195|/**************************************************************************
 196|  9. <<< プログラム実行関係、ファイルオープン >>> 
 197|***************************************************************************/
 198|int   WinX_call( const char* cmdline );
 199|void  WinX_openHtml( const char* url, bool bNewWnd );
 200|void  WinX_openByNotepad( const char* path );
 201|void  WinX_openFile( const char* path );
 202|void  WinX_openFile2( const char* path, const char* action );
 203|void  WinX_openFolder( const char* path );
 204|void  WinX_openFolder2( const char* path, bool bTree, const char* rootPath );
 205|void  WinX_openExplorer( const char* path );
 206| 
 207|/**************************************************************************
 208|  10. <<< エクスプローラメニュー関係 >>> 
 209|***************************************************************************/
 210|
 211|#ifdef  USES_BIGSTACK
 212|  void  WinX_setExtApp( const char* ext, const char* explain,
 213|    const char* actionName, const char* actionTitle, const char* command,
 214|    const char* iconPath, int iconNum, bool bDefault, bool bDownChk );
 215|  void  WinX_setFolderApp( const char* actionName, const char* actionTitle,
 216|    const char* command, bool bDefault );
 217|  void  WinX_unsetExtApp( const char* ext, const char* actionName );
 218|  void  WinX_unsetFolderApp( const char* actionName );
 219|  void  WinX_setNewFile( const char* ext, const char* newPath );
 220|  void  WinX_unsetNewFile( const char* ext );
 221|  bool  WinX_isNeedSecurity( const char* ext );
 222|  char*  WinX_getShellNewPath(void);
 223|#endif  /* USES_BIGSTACK */
 224|
 225|void  WinX_setIcon( const char* ext, const char* path, int iIcon );
 226|void  WinX_getIcon( const char* ext, char* path, int* iIcon );
 227|int   WinX_getFTypeInfos( const char* ext, WinX_FType* types, int types_size,
 228|  bool bAll, WinX_FType** defType );
 229|
 230|void  WinX_flush(void);
 231| 
 232|/**************************************************************************
 233|  11. <<< インストール関係 >>> 
 234|***************************************************************************/
 235|#ifdef  USES_BIGSTACK
 236|
 237|bool  WinX_uninstallFolder( const char* folderPath, const char* appName,
 238|  const char* folderName );
 239|void  WinX_setAppUninstall( const char* appName,
 240|  const char* title, const char* command );
 241|void  WinX_unsetAppUninstall( const char* appName );
 242|
 243|#endif  /* USES_BIGSTACK */
 244|
 245|
 246|
 247|/**************************************************************************
 248|  12. <<< [WinX_Inst] インストール関係 >>>
 249|***************************************************************************/
 250|#ifdef  USES_BIGSTACK
 251|
 252|void  WinX_Inst_install( WinX_Inst*, const char* exePath, bool* enables, bool bSplitByVer );
 253|void  WinX_Inst_uninstall( WinX_Inst*, const char* exePath, bool* enables );
 254|/*void  WinX_Inst_getVersion( char* appName, char* ver, int ver_size );*/
 255|
 256|
 257|struct _WinX_Inst {
 258|  char*  appName;
 259|  char*  ver;
 260|
 261|  WinX_InstType*  types;
 262|  WinX_Uninst*  uninst;  /* NULL=アンインストーラなし */
 263|};
 264|
 265|struct _WinX_InstType {
 266|  char*  ext;        /* 拡張子、最後の配列要素には "NULL" を設定する, "*" "folder" 可 */
 267|  char*  explain;    /* タイプの説明 */
 268|  bool   bDownChk;   /* ダウンロード時にチェックするかどうか */
 269|  char*  iconPath;   /* アイコンファイル、またはアイコンのある実行ファイルのパス、NULL=標準exeパス */
 270|  int    iIcon;      /* 設定しない=-1 */
 271|  WinX_InstCmd*  cmds;
 272|};
 273|
 274|struct _WinX_InstCmd {
 275|  char*  name;      /* コマンド名、最後の配列要素には "NULL" を設定する */
 276|  char*  caption;   /* 右クリックメニューの表示内容 */
 277|  char*  exePath;   /* NULL=標準exeパス、標準exeからの相対パス */
 278|  char*  command;   /* コマンドライン、実行ファイルは指定しない */
 279|  WinX_DefType  defType;
 280|};
 281|
 282|struct _WinX_Uninst {
 283|  char*  uninstName;
 284|  char*  uninstCaption;
 285|  char*  uninstCmd;
 286|  char*  uninstFolderPath;  /* アンインストーラからの相対パス */
 287|};
 288|
 289|enum _WinX_DefType {
 290|  WinX_NotDef, WinX_Def, WinX_SubDef,
 291|};
 292|
 293|#endif  /* USES_BIGSTACK */
 294| 
 295|/**************************************************************************
 296|  13. <<< ドラッグ&ドロップ関係 >>> 
 297|***************************************************************************/
 298|int  WinX_startDrag( char** pathes, int nPath, int effects );
 299|
 300|#define  WinX_DragCopy  1
 301|#define  WinX_DragMove  2
 302|#define  WinX_DragLink  4
 303|
 304| 
 305|/**************************************************************************
 306|  14. <<< DDE関係 >>> 
 307|***************************************************************************/
 308|bool  WinX_isOpenDDE( const char* service, char* topic );
 309|void  WinX_sendDDE( const char* command, const char* service,
 310|  const char* topic, const void* data, int data_size, int sendType );
 311|int   WinX_receiveDDE( const char* command, const char* service,
 312|  const char* topic, void* data, int data_size );
 313|
 314|enum { WinX_Request, WinX_Execute };
 315|
 316|
 317| 
 318|/**************************************************************************
 319|  15. <<< [WinX_DdeAct] ファイルタイプの DDE アクション >>> 
 320|【役割】
 321|・ファイルタイプに関連付けられたアクション(DDE を使用する)のタイプです。
 322|***************************************************************************/
 323|enum { WinX_DdeAct_size = 256 };
 324|
 325|struct _WinX_DdeAct {
 326|  char  command[_MAX_PATH];         /* コマンド・パス */
 327|  char  service[WinX_DdeAct_size];  /* DDE サービス名(アプリ名)*/
 328|  char  topic[WinX_DdeAct_size];    /* DDE トピック名(プロパティ名)*/
 329|  char  data[WinX_DdeAct_size];     /* 転送データ・フォーマット */
 330|};
 331|
 332|void  WinX_DdeAct_init( WinX_DdeAct*, const char* type );
 333|bool  WinX_DdeAct_isOpen( WinX_DdeAct* );
 334|void  WinX_DdeAct_send( WinX_DdeAct*,
 335|  const char* topic, void* data, int data_size );
 336|void  WinX_DdeAct_receive( WinX_DdeAct*,
 337|  const char* topic, void* data, int data_size );
 338|
 339|
 340| 
 341|/**************************************************************************
 342|  16. <<< [WinX_FType] ファイルタイプの各アクションの情報 >>> 
 343|***************************************************************************/
 344|struct _WinX_FType {
 345|  char  name[64];
 346|  char  caption[64];
 347|  long  editFlags;  /*  0x00000001 (Secutiry) */
 348|  char  command[256];
 349|  bool  bDDE;
 350|  char  ddeMsg[64];
 351|  char  ddeApp[256];
 352|  char  ddeOpenCmd[256];
 353|  char  ddeTopic[64];
 354|};
 355| 
 356|/**************************************************************************
 357|  17. <<< [WinX_Autorun] CD-ROM 自動実行の情報 >>> 
 358|***************************************************************************/
 359|#define  WinX_Autorun_mShell  20
 360|
 361|struct _WinX_Autorun {
 362|  char  autorun_path[_MAX_PATH];
 363|  char  open[_MAX_PATH];
 364|  char  iconPath[_MAX_PATH];
 365|  int   iconNum;
 366|  int   nCommand;  /* captions と commands の配列要素数 */
 367|  char  captions[WinX_Autorun_mShell][256];
 368|  char  commands[WinX_Autorun_mShell][_MAX_PATH];   /* 第1添字は、caption と同じ */
 369|};
 370|
 371|void  WinX_Autorun_read( WinX_Autorun*, const char* path );
 372|void  WinX_Autorun_exec( WinX_Autorun*, int iCommand );
 373|char*  WinX_Autorun_getCmdPath( WinX_Autorun*, int iCommand,
 374|  char* exe_path, int exe_path_size );
 375| 
 376|#ifdef __cplusplus
 377|}
 378|#endif
 379|
 380|/*------------------------------------------------------------------------*/
 381|/* 18. <<<< Mapping Area ----------------------------------------------- >>>> */ 
 382|/*------------------------------------------------------------------------*/
 383|
 384| 
 385|/**************************************************************************
 386|  18-1. <<< [WinX_throw] 例外を投げる >>> 
 387|***************************************************************************/
 388|#define  WinX_throw( errcode )  WinX_throw_imp( errcode, __FILE__, __LINE__ )
 389| 
 390|/**************************************************************************
 391|  18-2. <<< [WinX_throwDde] DDE の 例外を投げる >>> 
 392|【引数】
 393|  ・DWORD  dde;    DdeInitialize の第1引数と同じ
 394|***************************************************************************/
 395|#define  WinX_throwDde( dde )   WinX_throwDde_imp( dde, __FILE__, __LINE__ )
 396|
 397| 
 398|/**************************************************************************
 399|  18-3. <<< [WinX_RegData_init] 初期化する >>> 
 400|***************************************************************************/
 401|#define  WinX_RegData_init( this, _data, _data_size ) \
 402|  ( (this)->type = 0, (this)->data = (_data), \
 403|    (this)->size = 0, (this)->maxSize = (_data_size) )
 404|
 405| 
 406|/**************************************************************************
 407|  18-4. <<< [WinX_RegNest_getIsKey] 現在のパスがキーかどうかを返す >>> 
 408|***************************************************************************/
 409|#define  WinX_RegNest_getIsKey( this ) \
 410|  ( (this)->bKey )
 411| 
 412|/**************************************************************************
 413|  18-5. <<< [WinX_RegNest_getDataCount] 現在のデータと残りのデータの数を返す >>> 
 414|***************************************************************************/
 415|#define  WinX_RegNest_getDataCount( this ) \
 416|  ( (this)->I[(this)->nest] - (this)->I[(this)->nest - 1] + 1 )
 417|
 418| 
 419|#endif 
 420| 
 421|