Javaアプリケーションからのウィンドウメッセージを使用してC#アプリケーションと通信する必要があります。私のアプリケーションからは、通信に使用するメッセージを登録します。私は正常にC#アプリケーションのウィンドウハンドルを取得し、メッセージを登録することができます。 C#アプリケーションは、WM_COPYDATA応答メッセージを送信してメッセージに応答します。 私はWM_COPYDATAが受信されるポイントに到達できます。しかし、私はどのように応答メッセージからメッセージの内容を抽出するか分からない。ウィンドウメッセージングを使用したJAVAとC#間のアプリケーション間通信
jniwrapとwinpackライブラリを使用して、JavaアプリケーションからWM_COPYDATAメッセージのコンテンツを読み込むサンプルコードを取得できれば本当に役に立ちます。 lParamの内容が構造型の場合に役立ちます。
私は、次のコードは、そのウィンドウ名で、他のアプリケーションのウィンドウハンドルを取得する要求メッセージと応答メッセージのために登録すると、空のコンテンツで要求メッセージを送信する機密データに
を削除するためにコードを編集する必要がありました。
private Library user32;
private long appHandle;
public void sendRequest() {
long requestMsgId = (int)this.registerWindowMessage("WM_TBD_SN_REQEST");
long responseMsgId = (int)this.registerWindowMessage("WM_TBD_SN_RESPONSE");
long tbdHandle = findWindow(null, "TestApp");
this.sendWindowsMessage(new Handle(tbdHandle), new Int(requestMsgId), new Handle(this.appHandle), new Pointer.Void());
}
public long sendWindowsMessage(final Parameter... args) {
final Function sendMessage = this.user32.getFunction("SendMessageA");
LongInt longInt = new LongInt();
sendMessage.invoke(longInt, args);
return longInt.getValue();
}
public long findWindow(final String classname, final String windowName) {
final Function findWindow = this.user32.getFunction("FindWindowA");
Parameter cName = null;
if (classname == null || classname.equals("")) {
cName = new Pointer.Void();
}
else {
cName = new AnsiString(classname);
}
LongInt longInt = new LongInt();
findWindow.invoke(longInt, cName, new AnsiString(windowName));
return longInt.getValue();
}
public long registerWindowMessage(String message) {
final Function findWindow = this.user32.getFunction("RegisterWindowMessageA");
LongInt longInt = new LongInt();
findWindow.invoke(longInt, new AnsiString(message));
return longInt.getValue();
}
これは助けてください、私のアプリケーションのウィンドウ
public class MyWindowProc extends WindowProc {
@Override
public void callback() {
if (this._msg.getValue() == Msg.WM_COPYDATA) {
// I can get to this point, but not sure how I can get the information from the message
// The WM_TBD_SN_RESPONSE structure consists of four fields
// 1. hWnd Field --- window handle of the calling application...
// 2. msg Field --- WM_COPYDATA message code
// 3. wData Field --- TDB application's window handle
// 4. pData Field --- contains a CopyDataStruct
// CopyDataStruct.pData – contains the Serial Number ----> how to extract this?
// CopyDataStruct.dwData – contains the message code for WM_TBD_SN_RESPONSE (this should match responseMsgId)
}
else {
super.callback();
}
}
}
のネイティブPROCの代わりに置換されるカスタムウィンドウプロシージャ、です。前もって感謝します。
最初に試したことをお見せできますか? –
質問にコードを追加しました。ありがとうございました。 – Developer