ID: Q102700
5.50 MS-DOS kbtool kbcode kbbuglist kbfixlist
The information in this article applies to:
An attempt to use #pragma comment to place a text string into an executable module fails.
The sample code below demonstrates two methods to work around this problem. The first method declares a character array in the application that contains the string to embed in the file. This method places the string into the application's data segment. The second method is similar to the first except that the compiler places the string into the application's code segment, and therefore it does not consume space in the data segment. Either of these methods loads the string into memory when the application runs.
A third method is available to applications developed for the Microsoft Windows operating system. Place the string into a STRINGTABLE resource. If desired, you can specify the LOADONCALL attribute so the string is not loaded into memory until the application requires it.
Microsoft has confirmed this to be a problem in Microsoft LINK version 5.5 for MS-DOS. This problem was corrected in Microsoft LINK version 5.6 for MS-DOS. This is not a problem in Microsoft LINK version 1.0 for Windows NT.
The #pragma comment(exestr, <string>) statement places <string> into the object file. LINK places the string into the executable file; you can find it with an application that searches executable files for strings. However, the loader does not load the string into memory. You can use comment strings to store a version number or similar information into your executable file.
/*
* Compiler options needed: none
*/
#pragma comment(exestr, "Comment EXESTR")
/*
* Other methods
* char data_exestr[] = "Data EXESTR";
* char __based(__segname("_CODE"))code_exestr[] = "Code EXESTR";
*/
void main()
{
}
Additional reference words: 5.50 8.00 KBCategory: kbtool kbcode kbbuglist kbfixlist KBSubcatergory: LinkIss
Keywords : kb16bitonly
Solution Type : kbfix
Last Reviewed: September 17, 1997