我目前使用Com4j與我的Java應用程序中的iTunes進行通信,但不幸的是它不能與64位Java一起工作,看起來它永遠不會,因此我試圖使用替代方法所謂的雅各代替。將使用Com4j調用iTunes DLL的Java代碼轉換爲Jacob
兩個庫提供從DLL生成Java類的工具,所得類非常相似,它被直白地改變大部分的代碼,但林如何找到亞型
IITPlaylist object = itunes.createFolder(TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg());
IITUserPlaylist playlistFolder = object.queryInterface(IITUserPlaylist.class);
兩個失敗庫創建了IITPlaylist和IITUSerPlaylist類,但只有com4j提供了queryInterface類,並且沒有IITUserPlaylist實際上不是IITPlaylist的子類。
而且com4j提供的是方法,但是雅各不
if (next.is(IITFileOrCDTrack.class))
任何人都知道如何解決這些問題?
編輯: 取得了一些進展,但仍然沒有得到它的工作,有一個QueryInterface方法採用該類的GUID(包括大括號),我通過查看jacobgenlog.txt文件找到了guid當您在iTunes可執行文件上運行jacobgen時創建
然後返回另一個與子類相關的Dispatch對象,但是簡單的IVE所做的操作是無效的,那麼mising步驟是什麼?
private static final String USER_PLAYLIST_GUID = "{0A504DED-A0B5-465A-8A94-50E20D7DF692}";
IITPlaylist object = itunes.createFolder(TextLabel.SAVE_ITUNES_PLAYLIST_FOLDER.getMsg());
IITUserPlaylist playlistFolder = (IITUserPlaylist)object.QueryInterface(USER_PLAYLIST_GUID);
的是()功能是通過檢查的那種
IITTrack next = tracks.getItem(i);
if(next.getKind().equals(ITTrackKind.ITTrackKindFile))
的作品扳手更換是jacobgen getKind()方法是無效的Java,因爲他們試圖返回一個新的接口,以及當然,你不能實例化一個接口,所以我有如下
ITPlayListKind從
public interface ITPlaylistKind extends __MIDL___MIDL_itf_iTunesCOMInterface_0001_0081_0001 {
}
01去修改它們
到
public enum ITPlaylistKind {
ITPlaylistKindUnknown,
ITPlaylistKindLibrary,
ITPlaylistKindUser,
ITPlaylistKindCD,
ITPlaylistKindDevice,
ITPlaylistKindRadioTuner;
}
在IITUserPlaylist
public ITPlaylistKind getKind() {
return new ITPlaylistKind(Dispatch.get(this, "Kind").toDispatch());
}
到
public ITPlaylistKind getKind() {
return ITPlaylistKind.values()[Dispatch.get(this, "Kind").getInt()];
}
這個由我wasnt原來的想法,我的想法從顯示http://dot-totally.co.uk/software/itunescon/是的修改版本由jacobgen創建的iTunes類,我沒有發現它增加了很多,並決定堅持使用jacobgen生成的類。
+ 1讓我意識到雅各。要自己檢查一下(對不起,我不能幫你:-)) – 2011-03-02 10:43:17