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. TCHAR* argv[ ]

TCHAR* argv[ ]

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
12 Posts 4 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.
  • B baerten

    Hello, i need to call wmain(int argc,TCHAR* argv[],TCHAR* envp[]) but how to create the TCHAR* argv[] ? it's possible to get different strings of argv via argv[0] ... [1] ... [2] The number of elements is stored in argc but which lenght has a TCHAR String ? I need the lenght to set the size of my malloc Big thanks for help :)

    J Offline
    J Offline
    jk chan
    wrote on last edited by
    #2

    i didn't get your question. Do you know what is TCHAR ? it is just a tyepedef . If ur applicaiton is unicode TCHAR is wchar_t otherwise it is char.

    If u can Dream... U can do it

    B 1 Reply Last reply
    0
    • B baerten

      Hello, i need to call wmain(int argc,TCHAR* argv[],TCHAR* envp[]) but how to create the TCHAR* argv[] ? it's possible to get different strings of argv via argv[0] ... [1] ... [2] The number of elements is stored in argc but which lenght has a TCHAR String ? I need the lenght to set the size of my malloc Big thanks for help :)

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #3

      you don't call main() or winmain() - or whatever the entry point is called - yourself. the system does it when you launch the application. a TCHAR is a char or a wchar_t, depending if the UNICODE (and _UNICODE) macro has been defined. to pass parameters to you main function, add command line parameters, and they will end as strings in the argv array


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      B 1 Reply Last reply
      0
      • J jk chan

        i didn't get your question. Do you know what is TCHAR ? it is just a tyepedef . If ur applicaiton is unicode TCHAR is wchar_t otherwise it is char.

        If u can Dream... U can do it

        B Offline
        B Offline
        baerten
        wrote on last edited by
        #4

        yup, :doh: i'm stupid, i found the answer it works via char** than allocate different char* to the pointers :zzz: I think i must stop to take drugs X| (Joke)

        1 Reply Last reply
        0
        • T toxcct

          you don't call main() or winmain() - or whatever the entry point is called - yourself. the system does it when you launch the application. a TCHAR is a char or a wchar_t, depending if the UNICODE (and _UNICODE) macro has been defined. to pass parameters to you main function, add command line parameters, and they will end as strings in the argv array


          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          B Offline
          B Offline
          baerten
          wrote on last edited by
          #5

          I call the DOS Main from out my MFC Application. The DOS Prog should run hidden(no visualization) in a thread (not process) but thanks nevertheless for your answer

          T S 2 Replies Last reply
          0
          • B baerten

            I call the DOS Main from out my MFC Application. The DOS Prog should run hidden(no visualization) in a thread (not process) but thanks nevertheless for your answer

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #6

            baerten wrote:

            I call the DOS Main from out my MFC Application

            how are you achieving this ?


            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            B 1 Reply Last reply
            0
            • B baerten

              I call the DOS Main from out my MFC Application. The DOS Prog should run hidden(no visualization) in a thread (not process) but thanks nevertheless for your answer

              S Offline
              S Offline
              sunit5
              wrote on last edited by
              #7

              U should read some books which discuss about Windows Internal viz Programming Applications for Microsoft Windows by Jeff Richter,it has mentioned who calls winmain or main:-O

              never say die

              1 Reply Last reply
              0
              • T toxcct

                baerten wrote:

                I call the DOS Main from out my MFC Application

                how are you achieving this ?


                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                B Offline
                B Offline
                baerten
                wrote on last edited by
                #8

                I make a AllocConsole in a Thread, then i redirect the STD_OUTPUT_HANDLE of the hidden console to stdout then i start simply _tmain(...) In my MFC applic i can read the output with the function "ReadConsoleOutput" and it works, i get the characters in a buffer of CHAR_INFO

                T 1 Reply Last reply
                0
                • B baerten

                  I make a AllocConsole in a Thread, then i redirect the STD_OUTPUT_HANDLE of the hidden console to stdout then i start simply _tmain(...) In my MFC applic i can read the output with the function "ReadConsoleOutput" and it works, i get the characters in a buffer of CHAR_INFO

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #9

                  baerten wrote:

                  then i start simply _tmain(...)

                  i repeat my question : HOW ??


                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  B 1 Reply Last reply
                  0
                  • T toxcct

                    baerten wrote:

                    then i start simply _tmain(...)

                    i repeat my question : HOW ??


                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    B Offline
                    B Offline
                    baerten
                    wrote on last edited by
                    #10

                    char ** args; args = (char**) malloc ( 2*sizeof(char*)); args[0] = (char*)malloc(50*sizeof(char)); args[1] = (char*)malloc(50*sizeof(char)); strcpy(args[0],"C:\\....."); strcpy(args[1],"\restart"); _tmain(2,args,0);

                    T 1 Reply Last reply
                    0
                    • B baerten

                      char ** args; args = (char**) malloc ( 2*sizeof(char*)); args[0] = (char*)malloc(50*sizeof(char)); args[1] = (char*)malloc(50*sizeof(char)); strcpy(args[0],"C:\\....."); strcpy(args[1],"\restart"); _tmain(2,args,0);

                      T Offline
                      T Offline
                      toxcct
                      wrote on last edited by
                      #11

                      is your program calling its own _tmain() recursively ? :wtf:


                      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                      B 1 Reply Last reply
                      0
                      • T toxcct

                        is your program calling its own _tmain() recursively ? :wtf:


                        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                        B Offline
                        B Offline
                        baerten
                        wrote on last edited by
                        #12

                        Nope, the MFC Applic calls the _tmain of the DOS-Project I call the _tmain in a thread, which was created by clicking on a button

                        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