Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC help : code error 0000007B

MFC help : code error 0000007B

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comdebugging
17 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jawadali477

    hi,
    i'm developing GUI using MFC in vs2008. i have developed code and it builds fine but when i debug my code, it gives system error 0000007B. part of the code that gives this error is given below + variable initialization.

    int COMportNum= 3;
    portstream_fd COMstream;
    portstream_fd pstream;
    char COMportPrefix[10] = "COM";
    char COMportName[256];

    sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3

    strng = CString(COMportName);
    strng.Format(_T("%0.9s"), strng);
    SetDlgItemText(IDC_STAT, strng);

    set_baud_rate(BaudRate);
    COMstream = open_host_port(COMportName); //opens serial port COM3

    if ( COMstream == PORT_NOT_OPENED ) //conditional check if COM3 is opened
    {
    stw.Format(_T("%08X"), GetLastError()); //generates error if any
    SetDlgItemText(IDC_PTUPORT, stw);
    }
    else
    SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");

    can anyone please help me with this error.

    Regards
    Jawad

    enhzflepE Offline
    enhzflepE Offline
    enhzflep
    wrote on last edited by
    #2

    Hi there, I don't want to seem pedantic, though I will point out that this is not actually system error 0x0000007B, but rather the error-code of the last system function that failed. A system error is one generally regarded as having been generated by Windows itself (rather than just a 'helper' function) Something that you may choose to do which certainly clarifies the error is to display a description of the error. Have a look over here, for a method by which the code 0x7B may be turned into a text message.

    1 Reply Last reply
    0
    • J jawadali477

      hi,
      i'm developing GUI using MFC in vs2008. i have developed code and it builds fine but when i debug my code, it gives system error 0000007B. part of the code that gives this error is given below + variable initialization.

      int COMportNum= 3;
      portstream_fd COMstream;
      portstream_fd pstream;
      char COMportPrefix[10] = "COM";
      char COMportName[256];

      sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3

      strng = CString(COMportName);
      strng.Format(_T("%0.9s"), strng);
      SetDlgItemText(IDC_STAT, strng);

      set_baud_rate(BaudRate);
      COMstream = open_host_port(COMportName); //opens serial port COM3

      if ( COMstream == PORT_NOT_OPENED ) //conditional check if COM3 is opened
      {
      stw.Format(_T("%08X"), GetLastError()); //generates error if any
      SetDlgItemText(IDC_PTUPORT, stw);
      }
      else
      SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");

      can anyone please help me with this error.

      Regards
      Jawad

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #3

      The error message is (you can check it in WinError.h)

      // The filename, directory name, or volume label syntax is incorrect.

      What library are you using?

      Veni, vidi, vici.

      In testa che avete, signor di Ceprano?

      J 1 Reply Last reply
      0
      • J jawadali477

        hi,
        i'm developing GUI using MFC in vs2008. i have developed code and it builds fine but when i debug my code, it gives system error 0000007B. part of the code that gives this error is given below + variable initialization.

        int COMportNum= 3;
        portstream_fd COMstream;
        portstream_fd pstream;
        char COMportPrefix[10] = "COM";
        char COMportName[256];

        sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3

        strng = CString(COMportName);
        strng.Format(_T("%0.9s"), strng);
        SetDlgItemText(IDC_STAT, strng);

        set_baud_rate(BaudRate);
        COMstream = open_host_port(COMportName); //opens serial port COM3

        if ( COMstream == PORT_NOT_OPENED ) //conditional check if COM3 is opened
        {
        stw.Format(_T("%08X"), GetLastError()); //generates error if any
        SetDlgItemText(IDC_PTUPORT, stw);
        }
        else
        SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");

        can anyone please help me with this error.

        Regards
        Jawad

        A Offline
        A Offline
        Andy411
        wrote on last edited by
        #4

        As CPallini pointed out

        CPallini wrote:

        The error message is (you can check it in WinError.h)

        // The filename, directory name, or volume label syntax is incorrect.

        Are you sure COM3 exists on your machine? Did you try the format \\.\COM3 instead? What happens in set_baud_rate() and in open_host_port()? You have to open the COM-Port before changing the baudrate Cou can find some more hints on serial communication here: Communications Resources[^] [Edit]corrected spelling of memeber name :-O [/Edit]

        CPalliniC J 2 Replies Last reply
        0
        • A Andy411

          As CPallini pointed out

          CPallini wrote:

          The error message is (you can check it in WinError.h)

          // The filename, directory name, or volume label syntax is incorrect.

          Are you sure COM3 exists on your machine? Did you try the format \\.\COM3 instead? What happens in set_baud_rate() and in open_host_port()? You have to open the COM-Port before changing the baudrate Cou can find some more hints on serial communication here: Communications Resources[^] [Edit]corrected spelling of memeber name :-O [/Edit]

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #5

          Andy411 wrote:

          JPalini

          :-D

          Veni, vidi, vici.

          In testa che avete, signor di Ceprano?

          A 1 Reply Last reply
          0
          • CPalliniC CPallini

            Andy411 wrote:

            JPalini

            :-D

            Veni, vidi, vici.

            A Offline
            A Offline
            Andy411
            wrote on last edited by
            #6

            Oooouuuuuuch Sorry, I just corrected it. Sometimes I don't have any control on what my fingers are doing with the keyboard :rose:

            1 Reply Last reply
            0
            • CPalliniC CPallini

              The error message is (you can check it in WinError.h)

              // The filename, directory name, or volume label syntax is incorrect.

              What library are you using?

              Veni, vidi, vici.

              J Offline
              J Offline
              jawadali477
              wrote on last edited by
              #7

              basically i have the console program running fine (means having source file and header files). than i wanted to build GUI for this using MFC in vs2008. now i don't understand how to open serial port in MFC. code below shows how to open serial port in console programming using cmd prompt.

              COMportName[0] = ' ';
              while (COMportName[0] == ' ') {
              printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix);
              scanf("%d", &COMportNum);
              printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum);
              tmpChar = 'f';
              while ( (tmpChar != 'y') && (tmpChar != 'n') )
              tmpChar = ((char) tolower(getchar()));
              if ( tmpChar == 'y' )
              sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
              }
              tmpChar = 'f';
              while (tmpChar != 'y') {
              printf("\nEnter the baud rate the ptu is communicate at (default: 9600): ");
              scanf("%d", &BaudRate);
              printf("You selected %d. Is this OK? (enter 'y' or 'n'): ", BaudRate);
              tmpChar = 'f';
              while ( (tmpChar != 'y') && (tmpChar != 'n') )
              tmpChar = ((char) tolower(getchar()));
              }

               /\* initialize the serial port \*/
               set\_baud\_rate(BaudRate);
               COMstream = open\_host\_port(COMportName);
              
               if ( COMstream == PORT\_NOT\_OPENED )
                   { printf("\\nSerial Port setup error.\\n");
                     goto abnormal\_exit;  }
               printf("\\nSerial port %s initialized\\n", COMportName);
              
              CPalliniC T 2 Replies Last reply
              0
              • A Andy411

                As CPallini pointed out

                CPallini wrote:

                The error message is (you can check it in WinError.h)

                // The filename, directory name, or volume label syntax is incorrect.

                Are you sure COM3 exists on your machine? Did you try the format \\.\COM3 instead? What happens in set_baud_rate() and in open_host_port()? You have to open the COM-Port before changing the baudrate Cou can find some more hints on serial communication here: Communications Resources[^] [Edit]corrected spelling of memeber name :-O [/Edit]

                J Offline
                J Offline
                jawadali477
                wrote on last edited by
                #8

                yes COM3 is available and i have tried \\.COM3 and \\\\.\\COM3 both. basically i'm developing GUI via MFC in vs2008 for my console program. part of the code for opening serial port in console program is given below. i can't understand how to do it in MFC.

                COMportName[0] = ' ';
                while (COMportName[0] == ' ') {
                printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix);
                scanf("%d", &COMportNum);
                printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum);
                tmpChar = 'f';
                while ( (tmpChar != 'y') && (tmpChar != 'n') )
                tmpChar = ((char) tolower(getchar()));
                if ( tmpChar == 'y' )
                sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
                }
                tmpChar = 'f';
                while (tmpChar != 'y') {
                printf("\nEnter the baud rate the ptu is communicate at (default: 9600): ");
                scanf("%d", &BaudRate);
                printf("You selected %d. Is this OK? (enter 'y' or 'n'): ", BaudRate);
                tmpChar = 'f';
                while ( (tmpChar != 'y') && (tmpChar != 'n') )
                tmpChar = ((char) tolower(getchar()));
                }

                 /\* initialize the serial port \*/
                 set\_baud\_rate(BaudRate);
                 COMstream = open\_host\_port(COMportName);
                
                 if ( COMstream == PORT\_NOT\_OPENED )
                     { printf("\\nSerial Port setup error.\\n");
                       goto abnormal\_exit;  }
                 printf("\\nSerial port %s initialized\\n", COMportName);
                
                A 1 Reply Last reply
                0
                • J jawadali477

                  basically i have the console program running fine (means having source file and header files). than i wanted to build GUI for this using MFC in vs2008. now i don't understand how to open serial port in MFC. code below shows how to open serial port in console programming using cmd prompt.

                  COMportName[0] = ' ';
                  while (COMportName[0] == ' ') {
                  printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix);
                  scanf("%d", &COMportNum);
                  printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum);
                  tmpChar = 'f';
                  while ( (tmpChar != 'y') && (tmpChar != 'n') )
                  tmpChar = ((char) tolower(getchar()));
                  if ( tmpChar == 'y' )
                  sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
                  }
                  tmpChar = 'f';
                  while (tmpChar != 'y') {
                  printf("\nEnter the baud rate the ptu is communicate at (default: 9600): ");
                  scanf("%d", &BaudRate);
                  printf("You selected %d. Is this OK? (enter 'y' or 'n'): ", BaudRate);
                  tmpChar = 'f';
                  while ( (tmpChar != 'y') && (tmpChar != 'n') )
                  tmpChar = ((char) tolower(getchar()));
                  }

                   /\* initialize the serial port \*/
                   set\_baud\_rate(BaudRate);
                   COMstream = open\_host\_port(COMportName);
                  
                   if ( COMstream == PORT\_NOT\_OPENED )
                       { printf("\\nSerial Port setup error.\\n");
                         goto abnormal\_exit;  }
                   printf("\\nSerial port %s initialized\\n", COMportName);
                  
                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #9

                  jawadali477 wrote:

                  COMstream = open_host_port(COMportName);

                  I would use the debugger to watch COMportName content in both console and MFC applications.

                  Veni, vidi, vici.

                  In testa che avete, signor di Ceprano?

                  J 1 Reply Last reply
                  0
                  • J jawadali477

                    yes COM3 is available and i have tried \\.COM3 and \\\\.\\COM3 both. basically i'm developing GUI via MFC in vs2008 for my console program. part of the code for opening serial port in console program is given below. i can't understand how to do it in MFC.

                    COMportName[0] = ' ';
                    while (COMportName[0] == ' ') {
                    printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix);
                    scanf("%d", &COMportNum);
                    printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum);
                    tmpChar = 'f';
                    while ( (tmpChar != 'y') && (tmpChar != 'n') )
                    tmpChar = ((char) tolower(getchar()));
                    if ( tmpChar == 'y' )
                    sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
                    }
                    tmpChar = 'f';
                    while (tmpChar != 'y') {
                    printf("\nEnter the baud rate the ptu is communicate at (default: 9600): ");
                    scanf("%d", &BaudRate);
                    printf("You selected %d. Is this OK? (enter 'y' or 'n'): ", BaudRate);
                    tmpChar = 'f';
                    while ( (tmpChar != 'y') && (tmpChar != 'n') )
                    tmpChar = ((char) tolower(getchar()));
                    }

                     /\* initialize the serial port \*/
                     set\_baud\_rate(BaudRate);
                     COMstream = open\_host\_port(COMportName);
                    
                     if ( COMstream == PORT\_NOT\_OPENED )
                         { printf("\\nSerial Port setup error.\\n");
                           goto abnormal\_exit;  }
                     printf("\\nSerial port %s initialized\\n", COMportName);
                    
                    A Offline
                    A Offline
                    Andy411
                    wrote on last edited by
                    #10

                    Does the console programm run? And what's the code inside open_host_port()? Did you step through the code of open_host_port() in the debugger? Examine every return code of Win32 API-calls and check GetLastError(). What happens, if you just do a call to the CreateFile-function to open the COM-port, just like in this article Creating a Serial communication on Win32[^] I dont't think that this is an MFC problem,

                    D 1 Reply Last reply
                    0
                    • J jawadali477

                      basically i have the console program running fine (means having source file and header files). than i wanted to build GUI for this using MFC in vs2008. now i don't understand how to open serial port in MFC. code below shows how to open serial port in console programming using cmd prompt.

                      COMportName[0] = ' ';
                      while (COMportName[0] == ' ') {
                      printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix);
                      scanf("%d", &COMportNum);
                      printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum);
                      tmpChar = 'f';
                      while ( (tmpChar != 'y') && (tmpChar != 'n') )
                      tmpChar = ((char) tolower(getchar()));
                      if ( tmpChar == 'y' )
                      sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
                      }
                      tmpChar = 'f';
                      while (tmpChar != 'y') {
                      printf("\nEnter the baud rate the ptu is communicate at (default: 9600): ");
                      scanf("%d", &BaudRate);
                      printf("You selected %d. Is this OK? (enter 'y' or 'n'): ", BaudRate);
                      tmpChar = 'f';
                      while ( (tmpChar != 'y') && (tmpChar != 'n') )
                      tmpChar = ((char) tolower(getchar()));
                      }

                       /\* initialize the serial port \*/
                       set\_baud\_rate(BaudRate);
                       COMstream = open\_host\_port(COMportName);
                      
                       if ( COMstream == PORT\_NOT\_OPENED )
                           { printf("\\nSerial Port setup error.\\n");
                             goto abnormal\_exit;  }
                       printf("\\nSerial port %s initialized\\n", COMportName);
                      
                      T Offline
                      T Offline
                      TinyDevices
                      wrote on last edited by
                      #11

                      What a mix up of different naming conventions!

                      1 Reply Last reply
                      0
                      • A Andy411

                        Does the console programm run? And what's the code inside open_host_port()? Did you step through the code of open_host_port() in the debugger? Examine every return code of Win32 API-calls and check GetLastError(). What happens, if you just do a call to the CreateFile-function to open the COM-port, just like in this article Creating a Serial communication on Win32[^] I dont't think that this is an MFC problem,

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #12

                        Andy411 wrote:

                        I dont't think that this is an MFC problem,

                        I agree.

                        "One man's wage rise is another man's price increase." - Harold Wilson

                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                        1 Reply Last reply
                        0
                        • J jawadali477

                          hi,
                          i'm developing GUI using MFC in vs2008. i have developed code and it builds fine but when i debug my code, it gives system error 0000007B. part of the code that gives this error is given below + variable initialization.

                          int COMportNum= 3;
                          portstream_fd COMstream;
                          portstream_fd pstream;
                          char COMportPrefix[10] = "COM";
                          char COMportName[256];

                          sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3

                          strng = CString(COMportName);
                          strng.Format(_T("%0.9s"), strng);
                          SetDlgItemText(IDC_STAT, strng);

                          set_baud_rate(BaudRate);
                          COMstream = open_host_port(COMportName); //opens serial port COM3

                          if ( COMstream == PORT_NOT_OPENED ) //conditional check if COM3 is opened
                          {
                          stw.Format(_T("%08X"), GetLastError()); //generates error if any
                          SetDlgItemText(IDC_PTUPORT, stw);
                          }
                          else
                          SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");

                          can anyone please help me with this error.

                          Regards
                          Jawad

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #13

                          jawadali477 wrote:

                          char COMportPrefix[10] = "COM"; char COMportName[256]; sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3 strng = CString(COMportName); strng.Format(_T("%0.9s"), strng); SetDlgItemText(IDC_STAT, strng);

                          I'm thinking you could eliminate some overhead here. Try:

                          strng.Format(_T("COM%d"), COMportNum);

                          Note that this likely has nothing to do with why open_host_port() is not opening the port.

                          "One man's wage rise is another man's price increase." - Harold Wilson

                          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                          1 Reply Last reply
                          0
                          • J jawadali477

                            hi,
                            i'm developing GUI using MFC in vs2008. i have developed code and it builds fine but when i debug my code, it gives system error 0000007B. part of the code that gives this error is given below + variable initialization.

                            int COMportNum= 3;
                            portstream_fd COMstream;
                            portstream_fd pstream;
                            char COMportPrefix[10] = "COM";
                            char COMportName[256];

                            sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); // initialize serial port COM3

                            strng = CString(COMportName);
                            strng.Format(_T("%0.9s"), strng);
                            SetDlgItemText(IDC_STAT, strng);

                            set_baud_rate(BaudRate);
                            COMstream = open_host_port(COMportName); //opens serial port COM3

                            if ( COMstream == PORT_NOT_OPENED ) //conditional check if COM3 is opened
                            {
                            stw.Format(_T("%08X"), GetLastError()); //generates error if any
                            SetDlgItemText(IDC_PTUPORT, stw);
                            }
                            else
                            SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");

                            can anyone please help me with this error.

                            Regards
                            Jawad

                            S Offline
                            S Offline
                            soaringpilot
                            wrote on last edited by
                            #14

                            I do not recognize the open_host_port function, but it does not really matter. On some systems you need to add a ':' after COMx. Try sprintf(COMportName, "%s%d:", COMportPrefix, COMportNum); to get COM3: Cheers, Henryk

                            J 1 Reply Last reply
                            0
                            • CPalliniC CPallini

                              jawadali477 wrote:

                              COMstream = open_host_port(COMportName);

                              I would use the debugger to watch COMportName content in both console and MFC applications.

                              Veni, vidi, vici.

                              J Offline
                              J Offline
                              jawadali477
                              wrote on last edited by
                              #15

                              console program is running fine. problem is in MFC program. can you tell how to implement the console program, as mentioned, in MFC??

                              1 Reply Last reply
                              0
                              • S soaringpilot

                                I do not recognize the open_host_port function, but it does not really matter. On some systems you need to add a ':' after COMx. Try sprintf(COMportName, "%s%d:", COMportPrefix, COMportNum); to get COM3: Cheers, Henryk

                                J Offline
                                J Offline
                                jawadali477
                                wrote on last edited by
                                #16

                                i did what you suggested and now the error comes out to be 00000002 (i.e The system cannot find the file specified). and the outcome of

                                SetDlgItemText(IDC_STAT, strng);

                                is "COM3:".

                                S 1 Reply Last reply
                                0
                                • J jawadali477

                                  i did what you suggested and now the error comes out to be 00000002 (i.e The system cannot find the file specified). and the outcome of

                                  SetDlgItemText(IDC_STAT, strng);

                                  is "COM3:".

                                  S Offline
                                  S Offline
                                  soaringpilot
                                  wrote on last edited by
                                  #17

                                  OK, so this means you fixed one problem (I think), but now came up against another. I believe 7B meant that command format was wrong that is why I was suggesting the ':' the 2 means that system cannot find COM3. Are you sure that it exists. On a Windows PC you'd look in device manager. If it really exists then 7B probably means something else. That is about all I can help. Henryk

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups