INFO: Macros to Facilitate Porting Applications to Windows NT

Last reviewed: September 30, 1997
Article ID: Q100660
The information in this article applies to:
  • Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, 2.1, 4.0, 5.0

SUMMARY

Many applications written for Windows use variations of C Run-time functions which specifically use NEAR or FAR pointers. Applications written for Windows NT use the flat memory model, therefore, these function variations are not supported. When porting from Windows to Windows NT, calls to these functions will need to be modified.

MORE INFORMATION

The following is a list of macros that make the porting of applications to Microsoft Windows NT easier:

   // Windows NT Macros

   #if defined(WIN32)

   #define _fmemcpy(x,y,z)    memcpy(x,y,z)
   #define _fmemcmp(x,y,z)    memcmp(x,y,z)
   #define _fmemset(x,y,z)    memset(x,y,z)
   #define _fmemicmp(x,y,z)   memicmp(x,y,z)
   #define _fmemmove(x,y,z)   memmove(x,y,z)

   #define _fstrcpy(x,y)      strcpy(x,y)
   #define _fstrcmp(x,y)      strcmp(x,y)
   #define _fstrcat(x,y)      strcat(x,y)
   #define _fstrlen(x)        strlen(x)
   #define _fstricmp(x,y)     stricmp(x,y)
   #define _fstrstr(x,y)      strstr(x,y)
   #define _fstrncpy(x,y,z)   strncpy(x,y,z)
   #define _fstrncmp(x,y,z)   strncmp(x,y,z)
   #define _fstrupr(x)        strupr(x)
   #define _fstrlwr(x)        strlwr(x)
   #define _fstrchr(x,y)      strchr(x,y)
   #define _fstrrchr(x,y)     strrchr(x,y)
   #define _fstrnicmp(x,y,z)  strnicmp(x,y,z)
   #define _fstrpbrk(x,y)     strpbrk(x,y)

   #define _nfree(x)          free(x)
   #define _nmalloc(x)        malloc(x)

   #define _loadds

   #define NT_GetWndInstance(hwnd) (HINSTANCE)GetWindowLong(hwnd,
       GWL_HINSTANCE)

   #define NT_GetWndID(hwnd)       (UINT)GetWindowLong(hwnd, GWL_ID);

   #define NT_ParseWM_COMMAND(id, ntfy, hwnd, wPar, lPar) \
       (id = LOWORD(wPar), ntfy = HIWORD(wPar), hwnd = (HWND)lPar)

   #define NT_PostWM_COMMAND(hwnd, id, ntfy, hwndChild) \

   PostMessage(hwnd,WM_COMMAND,(UINT)MAKELONG(id,ntfy),(LONG)hwndChild)

   #define NT_SendWM_COMMAND(hwnd, id, ntfy, hwndChild) \
       SendMessage(hwnd,
   WM_COMMAND,(UINT)MAKELONG(id,ntfy),(LONG)hwndChild)

   #if !defined(LONG2POINT)
   #define LONG2POINT(l,pt) ((pt).x=(SHORT)LOWORD(l),
      (pt).y=(SHORT)HIWORD(l))
   #endif

   // Windows NT Equivalents for Windows

   #else
   #define NT_GetWndInstance(hwnd) (HINSTANCE)GetWindowWord(hwnd,
       GWW_HINSTANCE)

   #define NT_GetWndID(hwnd)       (UINT)GetWindowWord(hwnd, GWW_ID);

   #define NT_ParseWM_COMMAND(id, ntfy, hwnd, wPar, lPar) \
       (id = wPar, ntfy = HIWORD(lPar), hwnd = (HWND)LOWORD(lPar))

   #define NT_PostWM_COMMAND(hwnd, id, ntfy, hwndChild) \
       PostMessage(hwnd, WM_COMMAND, (UINT)id, MAKELONG(hwndChild, ntfy))

   #define NT_SendWM_COMMAND(hwnd, id, ntfy, hwndChild) \
       SendMessage(hwnd, WM_COMMAND, (UINT)id, MAKELONG(hwndChild, ntfy))

   #endif
Keywords          : CLngIss VCGenIss
Version           : WINDOWS NT:1.0,2.0,2.1,4.0,5.0;
Platform          : NT WINDOWS
Issue type        : kbinfo


================================================================================


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 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.