jdesktop java_winmsiwrapper.java 源代码在线查看 - JDesktop Integration Components (JDIC) 资源下载 虫虫电子下载站...

* Returns the number of fields in a record. * @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. * @throws IOException If fail to get fields count. */ public static int winMsiRecordGetFieldCount(int hRecord) throws IOException { int nFields = msiRecordGetFieldCount(hRecord); if (nFields != -1) { return nFields; } else { throw new IOException("MSI Record Get Field Count Failed!"); } } /** * Releases the result set for an executed view. * @param hView Handle to a view that is set to release. * @throws IOException If fail to close the view. */ public static void winMsiViewClose(int hView) throws IOException { if (msiViewClose(hView) != ERROR_SUCCESS) { throw new IOException("MSI View Close Failed!"); } } /** * Commits changes to a database. * @param hDatabase Handle to the database. * @throws IOException If fail to commit the changes. */ public static void winMsiDatabaseCommit(int hDatabase) throws IOException { if (msiDatabaseCommit(hDatabase) != ERROR_SUCCESS) { throw new IOException("MSI Database Commit Failed!"); } } /** * Apply the transform to the MSI database. * @param hDatabase Handle of the MSI database. * @param transformFile The MST file containing the transform information. * @throws IOException If fail to apply the transform. */ public static void winMsiDatabaseApplyTransform(int hDatabase, String transformFile) throws IOException { if (ERROR_SUCCESS != msiDatabaseApplyTransform(hDatabase, stringToByteArray(transformFile), 0)) { throw new IOException("MSI Database apply tranform failed!"); } } /** * Closes an open installation handle. * @param hAny Specifies any open installation handle. * @throws IOException If fail to close the handle. */ public static void winMsiCloseHandle(int hAny) throws IOException { if (msiCloseHandle(hAny) != ERROR_SUCCESS) { throw new IOException("MSI Close Handle Failed!"); } } /** * Sets a record stream field from a file. * @param hRecord Handle to the record. * @param iField Specifies the field of the record to set. * @param filePathStr Specifies the path to the file containing the stream. * @throws IOException If fail to set the stream into the record. */ public static void winMsiRecordSetStream(int hRecord, int iField, String filePathStr) throws IOException { if (msiRecordSetStream(hRecord, iField, stringToByteArray(filePathStr)) != ERROR_SUCCESS) { throw new IOException("MSI Record Set Stream Failed!"); } } /** * Reads bytes from a record stream field into a buffer. * @param hRecord Handle to the record. * @param iField Specifies the field of the record. * @return The read stream bytes. */ public static byte[] winMsiRecordReadStream(int hRecord, int iField) { return msiRecordReadStream(hRecord, iField); } /** * Opens Summary Information stream. * @param hDatabase Handle of the msi database. * @return Handle to the opened summary information, errorcode. */ public static int[] winMsiGetSummaryInformation(int hDatabase) { return msiGetSummaryInformation(hDatabase); } /** * Sets the property field of the msi summary information stream. * @param hSummaryInfo Handle of the msi summary information stream. * @param uiProperty Specify the property field. * @param strValue New value to be set. * @throws IOException If fail to set the property. */ public static void winMsiSummaryInfoSetProperty(int hSummaryInfo, int uiProperty, String strValue) throws IOException { if (msiSummaryInfoSetProperty(hSummaryInfo, uiProperty, stringToByteArray(strValue)) != ERROR_SUCCESS) { throw new IOException("MSI SummaryInfo Set Property Failed!"); } } /** * Flush the msi summary information stream. * @param hSummaryInfo Handle to the msi summary information stream. * @throws IOException If fail to do the flush. */ public static void winMsiSummaryInfoPersist(int hSummaryInfo) throws IOException { if (msiSummaryInfoPersist(hSummaryInfo) != ERROR_SUCCESS) { throw new IOException("MSI Summaryinfo Persist Failed!"); } } /** * Closes all open installation handles allocated by the current thread. * @return 0 if all handles are closed. Otherwise, the function returns * the number of handles open prior to its call. */ public static int winMsiCloseAllHandles() { return msiCloseAllHandles(); } /** * Generates a UUID string. * @return The generated UUID string if succeed or null if failed. */ public static String generateUUID() { byte[] newUUID = genUUID(); if (newUUID != null) { return byteArrayToString(newUUID); } else { return null; } } /** * Generate the transform MST file. * @param hDatabase Handle of the database. * @param hDatabaseReference Handle of the referenced database. * @param transformFile Path of the transform file. * @throws IOException If failed to generate the transform. */ public static void winMsiDatabaseGenerateTransform(int hDatabase, int hDatabaseReference, String transformFile) throws IOException { int result = msiDatabaseGenerateTransform( hDatabase, hDatabaseReference, stringToByteArray(transformFile)); if (result != ERROR_SUCCESS) { throw new IOException("MSI Database Generate Transform Failed!"); } } /** * Creates summary information of an existing transform to include * validation and error conditions. * @param hDatabase Handle of the database. * @param hDatabaseReference handle of the referenced database. * @param transformFile Path of the transform file. * @throws IOException If failed to generate the summary info transform. */ public static void winMsiCreateTransformSummaryInfo( int hDatabase, int hDatabaseReference, String transformFile) throws IOException { int result = msiCreateTransformSummaryInfo( hDatabase, hDatabaseReference, stringToByteArray(transformFile)); if (result != ERROR_SUCCESS) { throw new IOException("MSI Database Generate Transform Failed!"); } } /** * Windows API to import a database table from a txt file. * @param hDatabase The given database handle. * @param folderPath The directory path where the txt table file locates. * @param txtFileName The txt representation for the corresponding table. * @throws IOException If failed to import the database. */ public static void winMsiDatabaseImport( int hDatabase, String folderPath, String txtFileName) throws IOException { int result = msiDatabaseImport(hDatabase, stringToByteArray(folderPath), stringToByteArray(txtFileName)); if (ERROR_SUCCESS != result) { throw new IOException("MSI Databse import failed!"); } } /** * Windows API wrapper to add/update an executable file's resource * string table. * @param appFilePath The given application's file path. * @param contentStr The string to be added. * @param resID The given resource ID. * @throws IOException If fail to update the resource string. */ public static void winUpdateResourceString( String appFilePath, String contentStr, int resID) throws IOException { int result = updateResourceString(stringToByteArray(appFilePath), stringToByteArray(contentStr), resID); if (result != ERROR_SUCCESS) { throw new IOException("Windows Update Resource String Failed!"); } } /** * Windows API to add/update an executble file's binary resource. * @param appFilePath The given application's file path. * @param dataFilePath The given file containing the binary data * @param resID The given resource ID * @throws IOException If failed to update the binary resource field. */ public static void winUpdateResourceData( String appFilePath, String dataFilePath, int resID) throws IOException { int result = updateResourceData(stringToByteArray(appFilePath), stringToByteArray(dataFilePath), resID); if (result != ERROR_SUCCESS) { throw new IOException( "Windows Update Resource Binary Data Failed!"); } } /** * Windows API to create a MSI database record. * @param numFields Number of the fields to be included in this record. * @return Handle to the created record. * @throws IOException If failed to create the record. */ public static int winMsiCreateRecord(int numFields) throws IOException { int msiRecordHandle = msiCreateRecord(numFields); if (msiRecordHandle != -1) { return msiRecordHandle; } else { throw new IOException("MSI Create Record Failed!"); } }}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值