|
well if you are hooking MessageBoxA in a UNICODE exe then it won't be called unless you specify MessageBoxA instead of MessageBox.
Anyways i think you can use strcat in MyMessageBoxA if it hooks the non unicode version of MessageBox AKA MessageBoxA
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
|
What is the need to hook MessageBoxA here? Simply calling it should do.
_tcscat should do it.
Nibu thomas
Software Developer
-- modified at 1:18 Friday 24th March, 2006
|
|
|
|
|
Did you read the post?
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
hi All
i am unable to find erase background event in Dialog
based application, ihave read somewhere that it's np
longer supported in vc 6++. Is there any alternative
as i have to make my dialog flicker free
|
|
|
|
|
what do you mean you can't find, its right there.
BEGIN_MESSAGE_MAP(CMydialog, CDialog)
....
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
then add function to mydialog.h file
BOOL OnEraseBkgnd(CDC* pDC);
and add the body to mydialog.cpp file
BOOL CMydialog::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Hello All,
I've a MFC application from which I've to call a routine from a DLL.
EARLIER, This DLL was getting used by a JAVA application.
But now there is a MFC application instead.
We dont' have to change the DLL code for this in any case.
The export routines have following declaration:
JNIEXPORT void JNICALL Java_gui_config_setManufacturer(JNIEnv *env, jobject obj);
Please let me know how this routine can be called from MFC application.
Thanks in advance!
Regards!
|
|
|
|
|
a1prashant@yahoo.com wrote: JNIEXPORT void JNICALL Java_gui_config_setManufacturer(JNIEnv *env, jobject obj);
Please let me know how this routine can be called from MFC application.
Did you try calling it?
Nibu thomas
Software Developer
|
|
|
|
|
Thank you for replying.
Issue1: (Is passing NULL, NULL correct??)
typedef void * (__stdcall *DLLPROC)(VOID *, VOID *);<br />
...<br />
DLLPROC pfnProc = (DLLPROC)GetProcAddress(hInst, "Java_gui_Win_getCurrFirmware");<br />
if( pfnProc )<br />
{<br />
AfxMessageBox("Got Java_gui_Win_getCurrFirmware");<br />
VOID * jstr = (pfnProc)(NULL, NULL);
AfxMessageBox("Called!");<br />
}
While calling the procedure, it is expected to send (JNIEnv *env AND jobject *obj)
But currently I am passing NULL, NULL.
Is this correct?
The code runs w/o problem and I able to see the message box "Called".
Issue2: (How do I get c_str from "jstring")The DLL procedure is supposed to return "jstring"
But I need c_str out of it. How do I do the conversion?
I want conversions for atleast
jboolean -> boolean
jstring -> char *
jint -> int
Please help.
-- modified at 1:29 Friday 24th March, 2006
|
|
|
|
|
a1prashant@yahoo.com wrote: While calling the procedure, it is expected to send (JNIEnv *env AND jobject *obj)
JNIEnv and jobject are structures or classes that are declared in "java.h" or "jni.h" . Maybe copying them and passing the values as required should help.
Note: I am a bit tentative about this. I remember there is a file called java.h which contains declarations. Please check the file names. Maybe doing a string search inside java directory should help you. Strings like jobject , JNIEnv . This will take you to the exact file where they are declared.
a1prashant@yahoo.com wrote: But currently I am passing NULL, NULL.
Why?
a1prashant@yahoo.com wrote: Is this correct?
This is wrong. They are expecting something but you are giving nothing!
a1prashant@yahoo.com wrote: (How do I get c_str from "jstring")The DLL procedure is supposed to return "jstring"
Take a look at what jstring is. What kind of datatype is it. Normally these are typedefs or structs . So it must be easy for you once you find them to use them and pass them to funtions.
a1prashant@yahoo.com wrote: I want conversions for atleast
jboolean -> boolean
jstring -> char *
jint -> int
Again I repeat what I said. These are either typedefs or structs . You can copy their declarations.
Nibu thomas
Software Developer
|
|
|
|
|
Thanks a lot for the help.
|
|
|
|
|
Well did it work?
Nibu thomas
Software Developer
|
|
|
|
|
Take a look at these links too...
Java.h[^]
Jni.h[^]
Nibu thomas
Software Developer
|
|
|
|
|
I included the jni.h and jni_md.h files.
However I wonder if following is okay?
The JVM passes JNIEnv and jobjects to the DLL.
Don't know how JVM treats these two parameters before passing.
hInst = ::LoadLibrary("D:\\win_dll.dll");<br />
if( hInst )<br />
{<br />
AfxMessageBox("Loaded win_dll.dll");<br />
typedef void * (__stdcall *fpProc)(JNIEnv *env , jobject obj);<br />
fpProc pfnProc = (fpProc)GetProcAddress hInst, "Java_gui_Win_getCurrFirmware");<br />
if( fpProc )<br />
{<br />
AfxMessageBox("Got Java_gui_Win_getCurrFirmware");<br />
<br />
JNIEnv env;<br />
jobject obj;<br />
VOID * jstr = (fpProc)(&env, obj);
<br />
<br />
AfxMessageBox("Called!");
Thanks!
|
|
|
|
|
a1prashant@yahoo.com wrote: JNIEnv env;
jobject obj;
VOID * jstr = (fpProc)(&env, obj); // Passing w/o initializing
Have you looked at the members of JNIEnv and jobject .
I guess jobject is an empty class.
JNIEnv is a huge class.
What happens when you pass an empty object of JNIEnv to the function. I guess the function will fill it out for you.
Nibu thomas
Software Developer
|
|
|
|
|
It works w/o problem. Actually I'm trying on a sample code, and yet the DLL is not fully loaded.
I'll have to check it after all the things are in place.
Great help Nibu!
Thanks!
|
|
|
|
|
a1prashant@yahoo.com wrote: I'll have to check it after all the things are in place.
Are you checking the output that you get from the function? Well I would like to know!
Nibu thomas
Software Developer
|
|
|
|
|
Hello Nibu,
Sorry for the delayed reply. 2 Day's holiday
I'll soon check it on one of my test machines. And I'll surely let you know the result.
Regards,
Pacific
|
|
|
|
|
I was also having two days holiday.
If it works please tell me. Will be waiting for your response.
Nibu thomas
Software Developer
|
|
|
|
|
When changed an ActiveX object's property by using its property page, clicking on the "Apply" button should reflect the changes to ActiveX object. However, this does not work with my own ActiveX control and clicking on the "Apply" button simply does nothing.
If you know where to put in event handling code for clicking on this "Apply" button, please let me know. Thank you in advance.
|
|
|
|
|
What I'm trying to do is search a binary file for a specified string then copy all of the data in between strings into other files. What commands should I look at that could help me do this? Thanks.
|
|
|
|
|
The easiest way would be the load the whole file into memory, do the search, and then copy the bit you want into the new file (unless the file is so big and that this isn't feasable).
------------------
// Copy.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <tchar.h>
#include <algorithm>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Open the file.
HANDLE hFile = CreateFile(
_T("C:\\a.txt"), // lpFileName,
FILE_READ_DATA, // dwDesiredAccess
FILE_SHARE_READ, // dwShareMode,
NULL, // lpSecurityAttributes
OPEN_EXISTING, // dwCreationDisposition
FILE_ATTRIBUTE_NORMAL, // dwFlagsAndAttributes
NULL // hTemplateFile
);
if ( hFile==INVALID_HANDLE_VALUE )
{
return 1;
}
DWORD dwFileSize = GetFileSize(hFile, NULL);
// Create the file mapping.
HANDLE hMapping = CreateFileMapping(
hFile, // hFile
NULL, // lpAttributes
PAGE_READONLY, // flProtect
0, // dwMaximumSizeHigh
0, // dwMaximumSizeLow
NULL // lpName
);
if ( hMapping==NULL )
{
// Close the file.
CloseHandle(hFile);
return 1;
}
LPVOID pData = MapViewOfFile(
hMapping, // hFileMappingObject
FILE_MAP_READ, // dwDesiredAccess
0, // dwFileOffsetHigh
0, // dwFileOffsetLow
0 // dwNumberOfBytesToMap
);
if ( pData==NULL )
{
// Close the file mapping.
CloseHandle(hMapping);
// Close the file.
CloseHandle(hFile);
return 1;
}
// Now search for the data we want...
// The file data we've loaded.
const char *pStart = reinterpret_cast<const char *>(pData);
const char *pEnd = pStart + dwFileSize;
// The data we're looking for.
const char DataToFind[] = "|Hello|";
const char *pSearchStart = DataToFind;
const char *pSearchEnd = pSearchStart+sizeof(DataToFind)-1; // -1 to strip off the NULL terminator.
// Search.
const char *pMatch = std::search(pStart, pEnd, pSearchStart, pSearchEnd);
if ( pMatch!=pEnd )
{
pMatch += sizeof(DataToFind)-1;
const char *pMatch2 = std::search(pMatch, pEnd, pSearchStart, pSearchEnd);
if ( pMatch2!=pEnd )
{
// Copy out [pMatch, pMatch2).
// Create the output file.
HANDLE hOut = CreateFile(
_T("C:\\out.txt"), // lpFileName,
GENERIC_WRITE, // dwDesiredAccess
0, // dwShareMode,
NULL, // lpSecurityAttributes
CREATE_ALWAYS, // dwCreationDisposition
FILE_ATTRIBUTE_NORMAL, // dwFlagsAndAttributes
NULL // hTemplateFile
);
if ( hOut!=INVALID_HANDLE_VALUE )
{
DWORD dwWritten;
WriteFile(hOut, pMatch, pMatch2-pMatch, &dwWritten, 0);
CloseHandle(hOut);
}
}
}
// Unmap the file.
UnmapViewOfFile(pData);
// Close the file mapping.
CloseHandle(hMapping);
// Close the file.
CloseHandle(hFile);
return 0;
}
Steve
|
|
|
|
|
Steve, if you place code inside of <pre> tags you don't have to fiddle around entering tons of s in a failed effort to line things up.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I ticked ignore HTML tags for this one.
|
|
|
|
|
Thanks! This helps me out a lot. I've got a question about the code, though. How do I get it to repeat until the end of the file and how do I make it take the string I was searching for as well?
Example:
|Hello|abcdef|Hello|ghijkl|Hello|mnopqr|Hello|stuvwx|Hello|yz
Then it would output |Hello|abcdef to file1.txt, |Hello|ghijkl to file2.txt, etc.
Sorry if this is asking too much, I'm pretty new to VC++ (I normally code mixed C/++) and handling files. Thanks again for the help.
|
|
|
|