swt其实包装了很多操作系统上比较底层的操作,通过查看swt的源代码就可以知道使用方法 根据名字获得guid,没有获得则返回空 private static GUID getClassID(String clientName) { GUID guid = new GUID(); char[] buffer = null; if (clientName != null) { int count = clientName.length(); buffer = new char[count + 1]; clientName.getChars(0, count, buffer, 0); } if (COM.CLSIDFromProgID(buffer, guid) != COM.S_OK){ int result = COM.CLSIDFromString(buffer, guid); if (result != COM.S_OK) return null; } return guid; } 一般程序的调用逻辑 private static void setWpsWordAvailable() { GUID guid = getClassID(WPS_WORD_APP_NAME); isWpsWordAvailable = guid != null; } private static void setMsoWordAvailable() { GUID guid = getClassID(MSO_WORD_APP_NAME); isMsoWordAvailable = guid != null; } public static String getWordAppName() { if (isMsoWordAvailable) return MSO_WORD_APP_NAME; if (isWpsWordAvailable) return WPS_WORD_APP_NAME; return null; }