我在 Lotus Notes 9 C API 的演示程序中找不到错误

问题描述

我是 Lotus Notes C 开发的新手。我正在尝试使用 LN 9 C API 创建一个程序。我在 Visual Studio 2019 免费版中使用 C API 演示程序。我的电脑上安装了 Lotus Notes 9。

我已经设法解决了依赖问题,但我无法修复两个错误

“数组的大小必须大于零” “负下标” 错误在 winnt.h 行 2501

有什么想法吗?谢谢!

这是我试图让它工作的演示程序

PROGRAM:    INTROWIN

PURPOSE:    Windows version of IBM C API for Notes/Domino sample
            introductory program that opens a Domino database and
            displays the database title.


FUNCTIONS:

WinMain() -           Call initialization function,process
                      message loop.
InitApplication() -   Init window data and register window.
InitInstance() -      Save instance handle,create main window.
MainWndProc() -       Process messages.
Getdbname() -         Process messages for "Getdbname" dialog Box.

COMMENTS:

    Windows can have several copies of your application running at the
    same time.  The variable hInst keeps track of which instance this
    application is so that processing will be to the correct window.

           #include <windows.h>            /* required for all Windows apps */
    
        /* Standard Library Include Files */
    
        #include <stdlib.h>
        #include <string.h>
    
        /* DOMINO AND NOTES INCLUDE FILES */
    
        #include <global.h>
        #include <osmisc.h>
        #include <nsfdb.h>
    
        /* LOCAL INCLUDE FILES */
    
        #include "introwin.h"
    
        extern int      __argc;
        extern char **  __argv;
    
        /*  Local Defines */
    
        #if !defined(ND64) 
            #define DHANDLE HANDLE 
        #endif
    
        #define LINEOTEXT   256
    
        //LRESULT FAR PASCAL MainWndProc (HWND hWnd,UINT message,//                                WParaM wParam,LParaM lParam);
        /* static values */
    
        static HANDLE     hInst,hModule;             /* current instance,module handle.    */
        static DBHANDLE    hNotesDB = NULLHANDLE;
        static char    szDBFileNameString[LINEOTEXT]; /* String to hold filename
                                                         of database.  */
        static char    szErrorString[LINEOTEXT];      /* String to be used for
                                                         error messages. */
        static char    szBuffer[LINEOTEXT];           /* Info buffer. */
    
        static char    szDBTitleString[NSF_INFO_SIZE];    /* String to hold title
                                                         of database.   */
        /*************************************************************************
    
        FUNCTION: WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
        
        PURPOSE: calls initialization function,processes message loop
    
        COMMENTS:
    
        Windows recognizes this function by name as the initial entry point 
        for the program.  This function calls the application initialization
        routine,if no other instance of the program is running,and always 
        calls the instance initialization routine.  It then executes a message
        retrieval and dispatch loop that is the top-level control structure
        for the remainder of execution.  The loop is terminated when a WM_QUIT
        message is received,at which time this function exits the application 
        instance by returning the value passed by PostQuitMessage().
    
        If this function must abort before entering the message loop,it 
        returns the conventional value NULL.  
    
        *************************************************************************/
    
        int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdshow)
    
        {
            MSG     msg;         /* message.         */
            STATUS  nError;      /* Status of IBM C API for Notes/Domino call. */
    
            hModule = GetModuleHandle((LPSTR) "introwin");
            hInst = hInstance;
    
            /* Init the Domino and Notes runtime system. */
         nError = NotesInitExtended(__argc,__argv);
    
       /*
        *  If the call to NotesInit fails,display an error message
        *  and exit the program.
        */
    
       if (nError != NOERROR)
       {
           MessageBox (GetFocus(),"Unable to Initialize Notes!","introwin",MB_OK);
           return (FALSE);
       }
    
        if (!hPrevInstance)              /* Other instances of app running? */
        if (!InitApplication(hInstance)) /* Initialize shared things */
            return (FALSE);              /* Exits if unable to initialize  */
    
        /* Perform initializations that apply to a specific instance */
    
        if (!InitInstance(hInstance,nCmdshow))
            return (FALSE);
    
        /* Acquire and dispatch messages until WM_QUIT message is received. */
    
        while (GetMessage(&msg,/* message structure                  */
              (HWND) NULL,/* handle of window receiving the msg */
              (WORD) NULL,/* lowest message to examine          */
              (WORD) NULL))         /* highest message to examine         */
        {
        TranslateMessage(&msg);     /* Translates virtual key codes.   */
        dispatchMessage(&msg);      /* dispatches message to window.   */
        }
    
        NotesTerm();                /* Terminate the Domino and Notes runtime 
        system. */
    
    
        return (SIZET_TO_DWORD(msg.wParam));    /* Returns the value from PostQuitMessage */
        }

    /************************************************************************

    FUNCTION: InitApplication(DHANDLE)

    PURPOSE: Initializes window data and registers window class

    COMMENTS:

    This function is called at initialization time only if no other 
    instances of the application are running.  This function performs 
    initialization tasks that can be done once for any number of running 
    instances.  

    In this case,we initialize a window class by filling out a data 
    structure of type WNDCLASS and calling the Windows RegisterClass() 
    function.  Since all instances of this application use the same window 
    class,we only need to do this when the first instance is initialized.  


*************************************************************************/

BOOL InitApplication(hInstance)
HANDLE hInstance;               /* current instance         */
{
    WNDCLASS  wc;

    /*
     *  Fill in window class structure with parameters
     *  that describe the main window.
     */

    wc.style = (UINT) NULL;             /* Class style(s).        */
    wc.lpfnWndProc = MainWndProc;       /* Function for getting messages
                                            for windows of this class. */
    wc.cbClsExtra = 0;                  /* No per-class extra data.    */
    wc.cbWndExtra = 0;                  /* No per-window extra data.   */
    wc.hInstance = hInstance;           /* App. that owns the class.   */
    wc.hIcon = LoadIcon((DHANDLE) NULL,IDI_APPLICATION);
    wc.hCursor = LoadCursor((DHANDLE) NULL,IDC_ARROW);
    wc.hbrBackground = GetStockObject(WHITE_Brush); 
    wc.lpszMenuName =  "introwinMenu";   /* Menu name in .RC file. */
    wc.lpszClassName = "introwinClass"; /* Name used in CreateWindow call. */

    /* Register the window class and return success/failure code. */

    return (RegisterClass(&wc));

}


    /*************************************************************************
    
        FUNCTION:  InitInstance(DHANDLE,int)
    
        PURPOSE:  Saves instance handle and creates main window
    
        COMMENTS:
    
            This function is called at initialization time for every instance
            of this application.  This function performs initialization tasks
            that cannot be shared by multiple instances.  
    
            In this case,we save the instance handle in a static variable and
            create and display the main program window.  
            
    *************************************************************************/
    
    BOOL InitInstance(hInstance,nCmdshow)
        HANDLE  hInstance;      /* Current instance identifier.       */
        int     nCmdshow;       /* Param for first ShowWindow() call. */
    {
        HWND    hWnd;           /* Main window handle.                */
    
        /* Save the instance handle in static variable,which will be       */
        /* used in many subsequence calls from this application to Windows. */
    
        hInst = hInstance;
    
        /* Create a main window for this application instance.  */
    
        hWnd = CreateWindow(
            "introwinClass",/* See RegisterClass() call.    */
            "Intro Notes API program",/* Text for window title bar.   */
            WS_OVERLAPPEDWINDOW,/* Window style.                */
            CW_USEDEFAULT,/* Default horizontal position. */
            CW_USEDEFAULT,/* Default vertical position.   */
            CW_USEDEFAULT,/* Default width.               */
            CW_USEDEFAULT,/* Default height.              */
            (HWND) NULL,/* No parent.                   */
            (HMENU) NULL,/* Use the window class menu.   */
            hInstance,/* Owner of window.             */
            (LPVOID) NULL                     /* Pointer not needed.          */
        );
    
        /* If window Could not be created,return "failure" */
    
        if (!hWnd)
            return (FALSE);
    
        /*
         * Make the window visible; update its client area;
         *   Return "success"
         */
    
        ShowWindow(hWnd,nCmdshow);  /* Show the window          */
        UpdateWindow(hWnd);          /* Sends WM_PAINT message   */
        return (TRUE);               /* Returns value from PostQuitMessage */
    
    }
    
    /*************************************************************************
    
        FUNCTION: MainWndProc(HWND,UINT,WParaM,LParaM)
    
        PURPOSE:  Processes messages
    
        MESSAGES:
    
        WM_COMMAND    - application menu (Getdbname dialog Box)
        WM_DESTROY    - destroy window
    
        COMMENTS:
    
        To process the FILE_GET_DB_TITLE message,call MakeProcInstance()
        to get the current instance address of the Getdbname() function.  Then
        call Dialog Box which will create the Box according to the information
        in the introwin.rc file and turn control over to the Getdbname()
        function.  When it returns,free the instance address.
    
    *************************************************************************/
    
    long FAR PASCAL MainWndProc(HWND hWnd,WParaM wParam,LParaM lParam)
    
    {
        FARPROC lpProcgetdbname;     /* pointer to the "Getdbname" function */
        STATUS  nError = NOERROR;
        int     iError;                     /* Ret code from DialogBox call */
        char    szTempString[LINEOTEXT];    /* Temp string used in building
                                               the database title string.  */
        switch (message)
        { 
           case WM_COMMAND:       /* message: command from app.  menu */
              switch (wParam)
              { 
              case FILE_GET_DB_TITLE:
    
                lpProcgetdbname = MakeProcInstance(Getdbname,hInst);
    
                /*
                 *  The Getdbname dialog proc prompts the user for the
                 *  filename of the database.  The procedure stores the
                 *  filename in the character string szDBFileNameString.
                 */
    
                iError = DialogBox(hInst,/* current instance */
                                   "GetdbnameDlg",/* resource to use  */
                                   hWnd,/* parent handle    */
                                   (DLGPROC)lpProcgetdbname);  /* instance address */
                                   
                FreeProcInstance(lpProcgetdbname);
                
                if (iError != TRUE)          /* If user pressed CANCEL,*/
                    goto RETURN;             /* don't open database. */
    
                /*
                 *   If no filename was entered,display an
                 *   appropriate error message.
                 */
                     
                if (szDBFileNameString[0] == (char) NULL)
                {
                    MessageBox (GetFocus(),"No Filename entered","ERROR",MB_OK);
                    goto RETURN;
                }
    
                /*
                 * Open the specified database.  display
                 * error message if the open fails.
                 */
                     
                nError = NSfdbOpen (szDBFileNameString,&hNotesDB);     /* Open database */
                if (nError != NOERROR)
                { 
                    osloadString(hModule,ERR(nError),szErrorString,LINEOTEXT-1);
                    MessageBox (GetFocus(),"Notes Error",MB_OK);
                    goto RETURN;
                } 
    
                /*
                 *  Get the database title.  If the API call
                 *  fails,display an appropriate message
                 *  and close the database recently opened.
                 *
                 *  If the API call succeeds,display
                 *  the title of the database.
                 */
                 
                nError = NSfdbInfoGet (hNotesDB,szBuffer);
                if (nError != NOERROR)    
                {
                    osloadString(hModule,MB_OK);
                    NSfdbClose (hNotesDB);
                    goto RETURN;
                } 
    
    
    
                NSfdbInfoParse (szBuffer,INFOPARSE_TITLE,szDBTitleString,NSF_INFO_SIZE - 1);
    
    
    
                wsprintf(szTempString,"Database title: %s",(char far *) szDBTitleString);
                MessageBox (GetFocus(),szTempString,"Database Title",MB_OK);
    
                /* Clear strings for reuse. */
    
                szDBFileNameString[0] = ((char) NULL);
                szDBFileNameString[0] = ((char) NULL);
                szTempString[0] = ((char) NULL);
    
                /*
                 * Close the database.  display error message if the
                 * close operation fails.
                 */
                 
                if (nError = NSfdbClose (hNotesDB))
                {
                    osloadString(hModule,szDBFileNameString,MB_OK);
                }
    RETURN:     hNotesDB = NULLHANDLE;
                break;
    
              case FILE_QUIT:
                    
              /*
               * User chose to quit the program.  If the database
               * was left open,close it.  Then send the Windows
               * message to close the application window.
               */
                 
                  if (hNotesDB != NULLHANDLE)
                      NSfdbClose (hNotesDB);
    
                  hNotesDB = NULLHANDLE;
                  SendMessage (hWnd,WM_CLOSE,0L); 
                  break;
              }
    
              break;
    
           case WM_DESTROY:            /* message: window being destroyed */
                PostQuitMessage(0);
                break;
    
           default:                    /* Passes it on if unproccessed    */
                return (DefWindowProc(hWnd,message,wParam,lParam));
        } 
        return 0;
    } 
    
    /************************************************************************
    
        FUNCTION: Getdbname(HWND,WORD,LONG)
    
        PURPOSE:  Processes messages for "Getdbname" dialog Box
    
        MESSAGES:
    
        WM_INITDIALOG - initialize dialog Box
        WM_COMMAND    - Input received
    
        COMMENTS:
    
              No initialization is needed for this particular dialog Box,but TRUE must be returned to Windows.
    
              Wait for user to click on the "OK" button or the "CANCEL"
              button,then close the dialog Box.
    
    ***********************************************************************/
    
    BOOL FAR PASCAL Getdbname(HWND hDlg,WORD message,LParaM lParam)
    {
        switch (message)
        {
            case WM_INITDIALOG:         /* message: initialize dialog Box */
                 return (TRUE);
    
            case WM_COMMAND:            /* message: received a command */
                 switch (wParam)
                 {
                    case IDOK:          /* "OK" Box selected?         */
                         GetDlgitemText(hDlg,dbnAME_EDIT,LINEOTEXT-1);
                            
                         EndDialog(hDlg,TRUE);  /* Exits the dialog Box. */
                         return (TRUE);
                            
                    case IDCANCEL:      /* System menu close command? */
                         EndDialog(hDlg,FALSE); /* Exits the dialog Box.   */
                         return (TRUE);
                }
            break;
        }
        return (FALSE);                 /* Didn't process a message.  */
    }

introwin.h

    #define FILE_GET_DB_TITLE   WM_USER+100
#define FILE_QUIT       WM_USER+110

#define dbnAME_TEXT 100
#define dbnAME_EDIT 101

int PASCAL WinMain(HINSTANCE,int);
BOOL InitApplication(HANDLE);
BOOL InitInstance(HANDLE,int);
//LRESULT FAR PASCAL MainWndProc(HWND,LParaM);
long FAR PASCAL MainWndProc(HWND,LParaM);
BOOL FAR PASCAL Getdbname(HWND,LParaM);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...