Microsoft KB Archive/100660

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 15:01, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


INFO: Macros to Facilitate Porting Applications to Windows NT

Article ID: 100660

Article Last Modified on 12/2/2003



APPLIES TO

  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition



This article was previously published under Q100660


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: kbinfo kblangc kbarttypeinf KB100660