2025年4月16日 星期三

用 pythonnet 重塑群益 SKOrderLib,提升功能完整性

以前都使用 comtypes 來包裹群益 SKCOM API。然而,幾次API更新後,在處理 SKOrderLib 時,發現愈來愈多使用 comtypes 包裝後功能不完善,一些事件無法正常運作。因此,我嘗試使用 pythonnet 來包裝 SKCOM API (請參考這篇),結果 SKOrderLib 的功能得以順利運作。 以下是我比較 comtypes 和 pythonnet,最佳化 SKOrderLib 的實際經驗 ,用jupyter notebook來運行可以得到最好效果。     


comtypes 範例

很多功能呼叫後都沒有回應,向是 GetRealBalaceReport, GetMarginPurchaseAmountLimit 等,重複呼叫 GetRealBalaceReport,甚至只會顯示 SK_ERROR_QUERY_IN_PROCESSING, 不論是間隔多久,都不會再回傳正確資料。

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

pythonnet範例

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.