Hi,string customeMessage= " my arguments";
I'm sending a message (basically command line args) from c++ Application to a Java application using window message. I would need to extract the message(i.e command line arguments) in Java using JNA in the call back method. I have heard of something like custom message but I'm finding bit difficult to achieve this. Could anyone help me on how send the message and extract it as string in Java.
Thank you.
C++ Code:
Find the application window by name and send message to the application.
HWND hwndList = NULL;
EnumWindows(EnumWindowsProc, (LPARAM)hwndList);
if(_found)
{
ShowWindow(_hwnd, SW_RESTORE);
int check = SetForegroundWindow(_hwnd);
//HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParamCould anyone help me here to wrap the custome message and send through SendMessageAPI ???
DWORD err = GetLastError();
}
BOOL CALLBACK EnumWindowsProc(HWND hWnd, long lParam) {
char buff[255];
bool _found=false;
if (IsWindowVisible(hWnd)) {
string ourWindowName = "applicaton_name";
GetWindowTextA(hWnd, (LPSTR) buff, 254);
string windowName = buff;
int res = windowName.compare(ourWindowName);
if (res == 0)
{
_hwnd = hwnd;
_found = true;
}
printf("%S\n", buff);
}
return TRUE;
}
=======
public interface INativeLibrary extends StdCallLibrarypublic final int WM_USERMESSAGE= 0xC001;
{
static Map UNICODE_OPTIONS = new HashMap() {
{
put("type-mapper", W32APITypeMapper.UNICODE);
put("function-mapper", W32APIFunctionMapper.UNICODE);
}
};
final INativeLibrary instance = (INativeLibrary) Native.loadLibrary("user32",INativeLibrary.class, UNICODE_OPTIONS);
static int GWL_WNDPROC = -4;
LONG_PTR SetWindowLong(int hWnd, int nIndex, WindProc wndProc) throws LastErrorException;
dB. | Moscow - Geneva - Seattle - New York
dblock.org - @dblockdotorg