So basically I am working on converting a C# project to C++. And i am confused on how the beginning of the C# project works, it has the following code in it, and I am trying to make this C++ compatible, but I can't seem to find where the arguments are being passed through? I am just running the compiled exe file....Also am using Microsoft Visual 2010

static void Go(string[] args)
        {
            // call function above to find the game directory and store it in _gameDirectory
            _gameDirectory = FindGameDirectory();
            if (args.Length == 1)
            {
                if (args[0].Equals(@"addasm"))
                {
                    AddAsmToRootPatchFile();
                    return;
                }
                /*                if (args[0].Equals(@"test"))
                                {
                                    PatchAllDrs();
                                    return;
                                }*/
                if (args[0].Equals("createpatches"))
                {
                    // locates the file age2_x1.exe
                    var allExes = FindFiles(@"AoK-TC executables", @"age2_x1*.exe", null, null);
                    // create new emtpy list of string format to find any extra patch files
                    var allPatchedExes = new List<string>();
                    // finds any other already patched files in the directory.
                    try
                    {
                        allPatchedExes = new List<string>(FindFiles(@"Patched executables", @"age2_x1*_???*x???*.exe", null, null));
                    }
                    catch (FatalError)
                    {
                        // Happens if no patched exes are found. No problem!
                    }

                    // allExe's is the actual game exe
                    foreach (var exe in allExes)
                    {
                        // if other patched file contains the original exe inside of its list skip it
                        // and continue to the next exe in allExes
                        if (allPatchedExes.Contains(exe))
                        {
                            UserFeedback.Trace(@"Skipping patched exe '{0}'", exe);
                            continue;
                        }
                        // if it is not found in the already patched files, create a new patched file y converting it
                        ConvertPatchFile(exe);
                    }
                }
                // Generates errror
                else
                {
                    ShowUsage();
                }
                return;
            } // end if if statement

            // initialize new width and height as 0
            int newWidth = 0, newHeight = 0;

            // Some value if true or false may show showUsage();
            switch (args.Length)
            {
                case 0:
                    break;
                case 2:
                    {
                        if (!int.TryParse(args[0], out newWidth) || !int.TryParse(args[1], out newHeight))
                        {
                            ShowUsage();
                            return;
                        }

                    }
                    break;
                default:
                    ShowUsage();
                    break;
            }

A C# program needs a function called Main, for C++ this is main.
The syntax for arguments of Main is string[] args, I believe for main this is string args[]. Your function on line 1 is called Go?

The code above will never work, for many reasons:
1. as ddanbe said, C# needs Main() method to get started (so no Go() method - change the name to Main)
2. About _gameDirectory = FindGameDirectory() ? Where did you innisiate it? Its from no where now.
You cannot call in instance from outside of the static method, so you have to create a new one in the static Main method - where it all begins.
3. Whats this method: AddAsmToRootPatchFile(); ? Is it a static or now? If its not, it wont compile.

this for beginning
Mitja

Edited 5 Years Ago by Mitja Bonca: n/a

That was only a piece of the code, and I am sorry that i wasted your time looking at this, I realized after that the args may not be being used, and i took out all of the code for it, and its not being used.

This question has already been answered. Start a new discussion instead.