⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winmsiwrapper.java

📁 JDesktop Integration Components (JDIC)
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is * subject to license terms. *  * This program is free software; you can redistribute it and/or modify * it under the terms of the Lesser GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. *  * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. */ package org.jdesktop.jdic.packager.impl;import java.io.IOException;/** * Bottom layer java wrapper for Windows MSI APIs. */public class WinMsiWrapper {    static {        System.loadLibrary("WinMsiWrapper");    }    //MsiOpenDatabase constants    /**     * Create a new database, transact mode read/write.     */    public static final int MSIDBOPEN_CREATE         = 3;    /**     * Open a database direct read/write without transaction.     */    public static final int MSIDBOPEN_DIRECT         = 2;    /**     * Open a database read-only, no persistent changes.     */    public static final int MSIDBOPEN_READONLY       = 0;    /**     * Open a database read/write in transaction mode.     */    public static final int MSIDBOPEN_TRANSACT       = 1;    //MsiViewModify mode constants    /**     * Refreshes the information in the supplied record without changing the     * position in the result set and without affecting subsequent     * fetch operations.     */    public static final int MSIMODIFY_SEEK             = -1;    /**     * Refreshes the information in the record. Must first call MsiViewFetch     * with the same record.     */    public static final int MSIMODIFY_REFRESH          = 0;    /**     * Inserts a record.     */    public static final int MSIMODIFY_INSERT           = 1;    /**     * Updates an existing record.     */    public static final int MSIMODIFY_UPDATE           = 2;    /**     * Writes current data in the cursor to a table row.     */    public static final int MSIMODIFY_ASSIGN           = 3;    /**     * Updates or deletes and inserts a record into a table.     */    public static final int MSIMODIFY_REPLACE          = 4;    /**     * Inserts or validates a record in a table.     */    public static final int MSIMODIFY_MERGE            = 5;    /**     * Remove a row from the table.     */    public static final int MSIMODIFY_DELETE           = 6;    /**     * Inserts a temporary record.     */    public static final int MSIMODIFY_INSERT_TEMPORARY = 7;    /**     * Validates a record.     */    public static final int MSIMODIFY_VALIDATE         = 8;    /**     * Validate a new record.     */    public static final int MSIMODIFY_VALIDATE_NEW     = 9;    /**     * Validates fields of a fetched or new record.     */    public static final int MSIMODIFY_VALIDATE_FIELD   = 10;    /**     * Validates a record that will be deleted later.     */    public static final int MSIMODIFY_VALIDATE_DELETE  = 11;    //Error code    /**     * The function succeeded.     */    public static final int ERROR_SUCCESS               = 0;    /**     * Access was not permitted.     */    public static final int ERROR_ACCESS_DENIED         = 5;    /**     * An invalid or inactive handle was supplied.     */    public static final int ERROR_INVALID_HANDLE        = 6;    /**     * A validation was requested and the data did not pass.     */    public static final int ERROR_INVALID_DATA          = 13;    /**     * One of the parameters was invalid.     */    public static final int ERROR_INVALID_PARAMETER     = 87;    /**     * The database could not be opened as requested.     */    public static final int ERROR_OPEN_FAILED           = 110;    /**     * An invalid path was supplied.     */    public static final int ERROR_BAD_PATHNAME          = 161;    /**     * No records remain, and a NULL handle is returned.     */    public static final int ERROR_NO_MORE_ITEMS         = 259;    /**     * The handle is in an invalid state.     */    public static final int ERROR_INVALID_HANDLE_STATE  = 1609;    /**     * An invalid SQL query string was passed to the function.     */    public static final int ERROR_BAD_QUERY_SYNTAX      = 1615;    /**     * The database could not be created.     */    public static final int ERROR_CREATE_FAILED         = 1631;    /**     * A view could not be executed.     */    public static final int ERROR_FUNCTION_FAILED       = 1627;    /**     * Java wrapper for Windows MSI API MsiOpenDatabase.     * @param databasePath Specifies the full path or relative path to the     *        database file     * @param persist Receives the full path to the file or the persistence     *        mode. You can use the szPersist parameter to direct the     *        persistent output to a new file or to specify one of the     *        following predefined persistence modes.     * @return   result[0]: Pointer to the location of the returned database     *           handle if succeed.     *           result[1]: error code.     */    private static native int[] msiOpenDatabase(byte[] databasePath,                                                       int persist);    /**     * Java wrapper for Windows MSI API MsiDatabaseOpenView.     * @param hDatabase Handle to the database to which you want to open     *        a view object.     * @param szQuery Specifies a SQL query string for querying the database.     * @return result[0]: error code.     *         result[1]: Pointer to a handle for the returned view.     */    private static native int[] msiDatabaseOpenView(int hDatabase,                                                    byte[] szQuery);    /**     * Java wrapper for Windows MSI API MsiViewExecute.     * @param hView Handle to the view upon which to execute the query.     * @param hRecord Handle to a record that supplies the parameters.     * @return error_code     */    private static native int msiViewExecute(int hView, int hRecord);    /**     * Java wrapper for Windows MSI API MsiViewFetch.     * @param hView Handle to the view to fetch from.     * @return result[0]: error_code.     *         result[1]: handle for the fetched record.     */    private static native int[] msiViewFetch(int hView);    /**     * Java wrapper for Windows MSI API MsiRecordGetString.     * @param hRecord Handle to the record.     * @param iField Specifies the field requested.     * @return the returned string     */    private static native byte[] msiRecordGetString(int hRecord, int iField);    /**     * Java wrapper for Windows MSI API MsiRecordSetString.     * @param hRecord Handle to the record.     * @param iField Specifies the field of the record to set.     * @param szValue Specifies the string value of the field.     * @return error_code     */    private static native int msiRecordSetString(int hRecord,                                                 int iField,                                                 byte[] szValue);    /**     * Java wrapper for Windows MSI API MsiViewModify.     * @param hView Handle to a view.     * @param eModifyMode Specifies the modify mode.     * @param hRecord Handle to the record to modify.     * @return error_code     */    private static native int msiViewModify(int hView,                                            int eModifyMode,                                            int hRecord);    /**     * Java wrapper for Windows MSI API MsiRecordGetFieldCount.     * @param hRecord Handle to a record.     * @return If the function succeeds, the return value is the number of     *         fields in the record. If the function is given an invalid or     *         inactive handle, it returns -1 or 0xFFFFFFFF.     */    private static native int msiRecordGetFieldCount(int hRecord);    /**     * Java Wrapper for Windows API MsiCreateRecord.     * @param numRecords Number of fields to be created in this record     * @return If the function succeeds, the return type is the handle to     *         the record.     */    private static native int msiCreateRecord(int numRecords);    /**     * Java wrapper for Windows MSI API MsiViewClose.     * @param hView Handle to a view that is set to release.     * @return error_code     */    private static native int msiViewClose(int hView);    /**     * Java wrapper for Windows MSI API MsiDatabaseCommit.     * @param hDatabase Handle to the database.     * @return error_code     */    private static native int msiDatabaseCommit(int hDatabase);    /**     * Java wrapper for Windows MSI API MsiCloseHandle.     * @param hAny Specifies any open installation handle.     * @return error_code     */    private static native int msiCloseHandle(int hAny);    /**     * Java wrapper for Windows MSI API MsiRecordSetStream.     * @param hRecord Handle to the record.     * @param iField Specifies the field of the record to set.     * @param szFilePath Specifies the path to the file containing the stream.     * @return error_code     */    private static native int msiRecordSetStream(int hRecord,                                                 int iField,                                                 byte[] szFilePath);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -