|
Let us say i have a number of printf commands and strings in my code
eg printf("Hi"),printf("Hello") and other strings
Are all these strings stored in a string table automatically?
|
|
|
|
|
No. Those strings are not stored in the string table. I guess such strings are stored in the .rdata section of the binary where as the string table and its strings are stored in the .rsrc section of the binary file.
|
|
|
|
|
This (almost) exact same question was posted yesterday.
http://www.codeproject.com/Messages/3187912/Strings-in-EXE.aspx[^]
And I've a vague memory of it beign posted a couple of days before.
Are you both in the same class? Bidding for the same project!
I find it a little spooky...
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: Are you both in the same class?
Either that or he created 2 accounts in order to increase the penetration of this forum.
|
|
|
|
|
Nope. They weren't yesterday and probably they aren't today.
If you wish to know where are them, then use an editor able to show binary files content (in a meaningful way) as, for instance, Notepad++ with the Hex Editor plugin.
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]
|
|
|
|
|
|
Hi all,
I am trying to handle keyboard strokes. For handling ctrl+c i have written this piece of code in my PreTranslateMsg function
BOOL CKeyboardStroke::PreTranslateMessage(MSG* pMsg)
{
switch(pMsg->message)
{
case WM_KEYDOWN:
{
if(GetKeyState(VK_CONTROL) && (pMsg->wParam == 0x43))
{
CTest obj;
obj.DoModal();
}
if(GetKeyState(VK_CONTROL) && (pMsg->wParam == 0x56))
{
AfxMessageBox(_T("ctrl V"));
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
But my problem is when i press ctrl+c dialog box is opened and when i close it my application crashes.
Can anybody help me in this.
Thanks in advance
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
DoModal blocks the application at that point. It's not wise to block the application inside PreTranslateMsg. Try showing the dialog box in OnKeyDown handler or may be try this
if(GetKeyState(VK_CONTROL) && (pMsg->wParam == 0x43))
{
CTest obj;
obj.DoModal();
return TRUE;
}
|
|
|
|
|
thanku it worked
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi,
I am trying to automate the setting of text for a spincontrol through
a c++ program. The spinControl is in a different application.
The scenario is as follows:
There is an application which pops up a dialog box
which contains a Spincontrol. I want to set the text of
the spincontrol.
Input available: The Dialog box name and the control specifier of
the spincontrol.
Please colud someone help me.
Thanks in advance for any help.
|
|
|
|
|
If you are using same application, you can access the object.
The spinControl is in a different application.
But, if you are using different application, you can use RPC mechanism for update values.
http://msdn.microsoft.com/en-us/library/aa511491.aspx[^]
Thanks and Regards,
Selvam,
http://www.wincpp.com
|
|
|
|
|
Thanks for the reply..
I am writing a c++ program to automatically set the value of a spin control..
I have used UDM_SETPOS message in the SendMessage.
It is not able to set the value that i try to pass..
Any help will do.
|
|
|
|
|
From SetWindowPos documentation,
hWndInsertAfter
[in] Handle to the window that precedes the positioned window in the Z order.
I have a doubt. the window that 'precedes' the position window is on top of it or below it?
My understanding is that hWndInsertAfter is the window immediately on top of positioned window but I am feeling suspicious.
|
|
|
|
|
I believe hWndInsertAfter will be just below hWnd . Haven't tried this myself.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I wrote a generic template-based identifier class but am getting compilation errors with the is-equal operator. Anybody know how to fix this? The following code is a distillation of the problem. I get compilation errors for the conditional expressions within the assert()s. The error text in the comments is paraphrased from Visual 2008 C++ Express. I don't get these errors when the core type and the literal are an integral type, e.g., int. I assume this is due to implicit integral conversions.
#include <iostream>
#include <assert.h>
using namespace std;
class Name
{
public:
Name(const string t_) : t(t_) { }
Name() { }
Name(const Name & t_) : t(t_.t) { }
Name & operator=(const string & rhs) { t = rhs; return *this; }
operator const string & () const { return t; }
operator string & () { return t; }
private:
string t;
};
int main()
{
Name n1 = "bananas", n2 = "bananas";
assert(n1 == n2);
assert(n1 == "bananas");
}
I'm thinking I need to overload the == operator. I tried that but ran into even more problems.
FWIW, my identifier class is similar to BOOST_STRONG_TYPEDEF() except that I want to be able to use the core type (possibly with implicit conversion) as an initializer to the derived type and as an argument to a derived-type parameter. I also want to use the derived type as an initializer to the core type. Here's an example of that:
BOOST_STRONG_TYPEDEF(string, S)
void f(S s) { }
int main() { S s = "abc"; f("def"); string str = s; }
Thanks!
|
|
|
|
|
dplong wrote: I'm thinking I need to overload the == operator. I tried that but ran into even more problems.
Well I think you need. BTW what are the problems?
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]
|
|
|
|
|
Oh, sorry:
"I get compilation errors for the conditional expressions within the assert()s. The error text in the comments is paraphrased from Visual 2008 C++ Express."
Basically, how do I get rid of those errors? I would like to be able to
1. compare two instances of my Name class for equality and
2. compare an instance of Name with an instance of its core type, string.
Like pointers, I only need to cast, assign, and compare for equality/inequality. For example, it doesn't make sense to add identifiers, like adding GUIDs.
|
|
|
|
|
Think you'll find it useful to add a Name constructor that takes a const char*. Reason is that C++ won't do 2 implicit conversions to get a function/operator to match - the 2 implicit conversions in this case being const char* -> string -> Name. That also permits operator== (which you will need to define - it's not one of the standard compiler provided operators) between a Name and a string literal:
#include <iostream>
#include <assert.h>
using namespace std;
class Name
{
public:
Name(const char* t_) : t(t_) { }
Name(const string& t_) : t(t_) { }
Name() { }
Name(const Name & t_) : t(t_.t) { }
Name & operator=(const string & rhs) { t = rhs; return *this; }
operator const string & () const { return t; }
operator string & () { return t; }
private:
string t;
};
bool operator==(const Name& left, const Name& right) { return string(left)==string(right); }
int main()
{
Name n1 = "bananas", n2 = "bananas";
assert(n1 == n2);
assert(n1 == "bananas");
}
<div class="ForumSig">Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p</div>
|
|
|
|
|
Thanks a bunch, Stuart. I realized I had a few more situations to take into consideration, so this is the class now. It works like a charm.
#include <string>
#include <assert.h>
using namespace std;
class Name
{
public:
Name() { }
Name(const string & t_) : t(t_) { }
Name(const char * t_) : t(t_) { }
Name & operator=(const string & rhs) { t = rhs; return *this; }
Name & operator=(const char * rhs) { t = rhs; return *this; }
friend bool operator==(const Name & lhs, const Name & rhs) { return lhs.t == rhs.t; }
operator const string & () const { return t; }
operator string & () { return t; }
private:
string t;
};
int main()
{
char arr[] = "bananas";
char *arrP = arr;
string s = "oranges";
Name nn1 = s;
Name n0 = string("apples");
n0 = s;
n0 = arr;
n0 = arrP;
nn1 = n0;
Name nn2 = Name(nn1);
Name n1 = "bananas", n2 = "bananas";
assert(n1 == n2);
assert(n1 == string("bananas"));
assert(n1 == arr);
assert(n1 == arrP);
assert(n1 == "bananas");
}
This solution creates another problem for me, though. I was using the following template so that this behavior could be defined for any class, e.g., int, unsigned, and string:
template <class T, class D> class IdTemplate {
public:
IdTemplate() { }
IdTemplate(const T t_) : t(t_) { }
IdTemplate & operator=(const T & rhs) { t = rhs; return *this; }
friend bool operator==(const IdTemplate & lhs, const IdTemplate & rhs) { return lhs.t == rhs.t; }
operator T & () { return t; }
operator const T & () const { return t; }
private:
T t;
};
However, the doubling up of the constructor and assignment operator for both string and char * makes this rather difficult because, for example, int doesn't have to consider a "shadow" type like char *. Any ideas on how to generalize the solution so that it may be represented with a template?
modified on Tuesday, September 8, 2009 1:05 AM
|
|
|
|
|
This is probably a really simple question, but I can't get my head around it. The C library that is linked with most applications uses functions like memcpy , strcat and memset . These names all seem very counter-intuitive, in comparison to CopyMemory, ConcatenateStrings and SetMemory. Likewise for calloc when compared to AllocateCleanMemory. Why is this?
My first thought was that this preserved stack space, but then I realised that the stack holds addresses, instead of method names. The only other possibility that I can think of is that C programmers dislike excessive typing, and so prefer shorter method names. Is this the reason why, or is there a technical constraint on method name length?
|
|
|
|
|
Computafreak wrote: The only other possibility that I can think of is that C programmers dislike excessive typing
That's true.
Computafreak wrote: Is this the reason why, or is there a technical constraint on method name length?
Well, the linker deals also with function (methods have no place in C programmer's mind) names.
Another reason maybe historical: when the C library was firstly developed, Microsoft wasn't around... (More seriously there wasn't a plethora of functions to remember and low risk of name collisions, so, I suppose, using short names was reasonable).
BTW: C library functions have too long names for Klingon Developers.
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]
|
|
|
|
|
It probably was not intentional by K&R and early C developers, but short function names in the C standard library make sense. Like Huffman coding, the length of words that humans use are inversely proportional to their frequency. For example, "I" and "ventriloquist." Since standard-library functions are used more than the programmer's own functions, they are shorter.
|
|
|
|
|
The original C library was developed in the early days of UNIX when computers were slow and had very little storage to work with, and input/output devices that operated at fairly low speeds. In order to conserve space most library functions were named in six characters or less to prevent the compilers from taking forever to turn source into executable code. Because of that history many of the original names are still in existence.
|
|
|
|
|
C was developed as the system programming language for Unix. The C run-time library functions have LONG names compared to Unix shell commands....ls, rm, ps etc
In addition, I suspect there may have been a desire to keep identifier names short - when doing string comparisons, the worst-case time is O(N), so the smaller you make N (the string length in this case), the better. Remember, in 1970, a computer had much, much less processing power and storage bandwidth than your phone has these days...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I want to run a dialog box doing some setting before I open a new MDI child. I did following:
BOOL CMyApp::InitInstance()
{
....
if( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
....
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
PostMessage(pMainFrame->GetSafeHwnd(), WM_COMMAND, ID_FILE_NEW_SETING, (LPARAM)0);
return TRUE;
}
void CMainFrame::CMFileNewSetting()
{
PostMessage( WM_COMMAND, ID_FILE_NEW, (LPARAM)0);
.....
}
The code runs OK while I try to launch the app within the VisualStudio. But when I tried to run the App.exe, App.exe crashed. After debugging, I found out that "PostMessage( WM_COMMAND, ID_FILE_NEW, (LPARAM)0);" cause the App.exe crashed.
How can I correct this problem?
Best regards,
modified on Monday, September 7, 2009 5:13 PM
|
|
|
|