Java 응용 프로그램의 Window 메시징을 사용하여 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