FIX: No String in EXE from #pragma Comment(exestr

Last reviewed: September 16, 1997
Article ID: Q102700
5.50 MS-DOS kbtool kbcode kbbuglist kbfixlist

The information in this article applies to:

  • Microsoft LINK for MS-DOS, version 5.5
  • Microsoft C/C++ for MS-DOS, version 8.0, which is included with Microsoft Visual C++ for Windows, version 1.0

SYMPTOMS

An attempt to use #pragma comment to place a text string into an executable module fails.

RESOLUTION

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.

STATUS

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.

MORE INFORMATION

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.

Sample Code

/*
 * 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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.