|
|
If I have strings(variables) in my application, does these strings present in the string table of exe?
|
|
|
|
|
A string constant in your inline code (e.g. printf("A string"); ) is compiled into the data portion of the object file. Such a string can be found in the exe by reading the entire file and looking for 'printable' characters. However only strings that are declared in resource string tables can be found using the FindResource() function.
|
|
|
|
|
I have to display all the strings present in an EXE file (i.e. compiled CPP file present in debug folder). How do i do this? I have written the following code. Can u please tell me what the problem is?.
#include "stdafx.h"
#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "string.h"
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param);
char buffer[200];
int _tmain(int argc, _TCHAR* argv[])
{DWORD S;
LPCTSTR RT_String=NULL;
LONG_PTR aux_param=NULL;
BOOL q,r;
HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
q= MyStringCB(some_library,RT_String,buffer,aux_param);
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
return 0;
}
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param)
{ DWORD startId = ((DWORD)buffer - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{ LoadString(some_library, i,buffer,sizeof(buffer));
}
return TRUE;
}
|
|
|
|
|
choramale_vs wrote: LoadString(some_library, i,buffer,sizeof(buffer));
You are loading the string but you do not diplay it anywhere...
|
|
|
|
|
After displaying buffer value am getting a Blank Screen
|
|
|
|
|
Sorry, but this really does not explain your problem. From some of your other questions and answers I suggest you may need to study this item on Resources.
|
|
|
|
|
Literals are NOT stored in the string table, if I guessed what are you asking...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have printed "Hi" in my application.
If I want to retrieve "Hi" from an EXE.
What should I do?
|
|
|
|
|
Put your strings into a stringtable.
|
|
|
|
|
That's what how to put it into string table and then how to display it from EXE?
|
|
|
|
|
Create a resource file (.rc) and add your string(s) to the stringtable. Then you can simply load the strings with LoadString() or CString::LoadString() if you are using MFC.
|
|
|
|
|
Isn't there a string table which is automatically made?
How to retrieve from that string table?
|
|
|
|
|
Are you the same person as the thread starter? Or do you just have the exact same problem?
Anyway, it very much depends on how you created your application. If you used a Visual Studio wizard then you will possibly already have a resource script included in your project, depending on which app type you chose.
If not - and you are using Visual Studio - it's very simple to add resources to your project. Look at the documentation.
|
|
|
|
|
Hi
How to established connection in mysql without ODBC?
Plz help me
|
|
|
|
|
Hi all,
i want to use Menu on right click of ListCtrl,
i m using this code
void CTest::OnNMRClickList(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pia = (LPNMITEMACTIVATE)pNMHDR;
UINT flags;
DWORD pos = GetMessagePos();
CPoint point(LOWORD(pos), HIWORD(pos));
m_List.ScreenToClient(&point);
int nItem = m_List.HitTest(point, &flags);
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
::AppendMenu(hMenu, MF_STRING, 1, "Test1");
::AppendMenu(hMenu, MF_SEPARATOR,2, "");
::AppendMenu(hMenu, MF_STRING, 3, "Test2");
::AppendMenu(hMenu, MF_SEPARATOR,4, "");
::AppendMenu(hMenu, MF_STRING, 5, "Test3");
ClientToScreen(&point);
int sel = ::TrackPopupMenuEx(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,point.x,point.y,m_hWnd,NULL);
switch(sel)
{
case 1:
{
}
break;
case 3:
{
}
break;
case 5:
{
}
break;
}
}
*pResult = 0;
}
its working fine only one problem is here its not popup the menu on tip of mouse cursor.
please tell me where i m wrong.
please help me .
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: DWORD pos = GetMessagePos();
CPoint point(LOWORD(pos), HIWORD(pos));
m_List.ScreenToClient(&point);
I think perhaps this is where your problem lies. The list box returns the cursor position in the LPNMITEMACTIVATE structure. You will need to convert this position to its absolute screenvalues via
ClientToScreen(hWnd, &pia->ptAction);
and then use pia->ptAction.x and pia->ptAction.y in your call to TrackPopupMenuEx().
|
|
|
|
|
No its not working
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
What is not working? What have you tried, and what results do you see?
|
|
|
|
|
Now i m using like this
UINT flags;
DWORD pos = GetMessagePos();
CPoint point(LOWORD(pos), HIWORD(pos));
m_List.ScreenToClient(&point);
int nItem = m_List.HitTest(point, &flags);
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
::AppendMenu(hMenu, MF_STRING, 1, "Test1");
::AppendMenu(hMenu, MF_SEPARATOR,2, "");
::AppendMenu(hMenu, MF_STRING, 3, "Test2");
::AppendMenu(hMenu, MF_SEPARATOR,4, "");
::AppendMenu(hMenu, MF_STRING, 5, "Test3");
ClientToScreen(&pia->ptAction);
int sel = ::TrackPopupMenuEx(hMenu,TPM_LEFTALIGN|TPM_RETURNCMD,pia->ptAction.x,pia->ptAction.y,m_hWnd,NULL);
switch(sel)
{
case 1:
{
}
break;
case 3:
{
}
break;
case 5:
{
}
break;
}
}
but still when i right click on ListCtrl the menu not popup from tip of mouse cursor.
please help me.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
This looks correct now, so I am at a loss to understand why it does not poup at the correct location. Where does it appear on your system relative to the screen? You may also like to use the debugger to check the values of x and y before and after the ClientToScreen(&pia->ptAction); call.
|
|
|
|
|
Thanks its done now.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
How I will write a macro to check that weather the pointer is NULL or not and if NOT then delete it.
Ex;
CXyz * abcd = new CXyz();
// do some thing with *abcd
if (abcd != Null)
{
delete abcd;
abcd = NULL:
}
I have to write a macro so as not to write the code again
Or shall I write a function for the same but then what will be its prototype
Please tell me how and where to write the code for it.
|
|
|
|
|
That's even more simple than that: you don't even need to check if the pointer is NULL or not, the delete operator takes care of that. So, if you pass a NULL pointer to delete, nothing happens.
EDIT: BTW, no need to repost your question so quickly, this is a forum here, not a chat...
|
|
|
|
|
Does delete operator checks for NULL itself?
Well I have to assign NULL after deleting also.
How I will define it
#define DELETE(ptr)
Is this declareation of macro is correct?
If yes then whhere I Will write its functionality
|
|
|
|
|