Results 1 to 12 of 12

Thread: C++ File

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    C++ File

    Hello,
    Can someone tell me how to do this:
    I'm begginer with c++ i had just started learning the book and i want some help to learn something
    Can someone learn me how to make this:

    I use : Visual Studio 2010

    The job is this:

    Code :
    Code:
    /*Бърз и прост начин за заместване на краш команда
    //AntiCrash Prevent
    */
    for(int X=0; X < (int)strlen(Message);X++){
    if(Message[X] == '%'){
    Message[X] = '"';
    }
    }
    How to make this source to be a .dll file with name (for example: MFS.dll) and this file to read information from an .ini file (for example: MFS.ini, the .ini file must to be in the same folder where it is the .dll file if its not to show error that cant find the file MFS.ini (or you can show me how to put a path to read the file from other folder that will be good too to learn))

    MFS.ini:
    [code]
    // Разрешаване на проблема с краш командата
    // Fix The Crash Problem
    FixCrash = 1; // (0-Disable,1-Enable)

    If in the MFS.ini on the line
    FixCrash = 1;
    To use the source code as enabled , if its 0 to be disabled (not to use the source code)

    I will be in grat if someone learn me how to make this,
    Thanks in advance

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    To build your project as a DLL, go into your project properties and take a look under Configuration properties > General. Make sure the setting "Configuration type" is set to Dynamic Library (.dll).

    To read data from files, take a look at the ifstream class.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: C++ File

    so for check if file exist is with : GetFileAttributes()
    but how should i add it right, can you give me example
    to read info from .ini file should be : GetPrivateProfileString()
    can you also add a example how should do it so to add it in the source code to work

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    I have never used GetPrivateProfileString, and I dont think I would seeing as its not very portable for something so trivial as reading a file. But ok, use GetPrivateProfileString.
    The documentation for the function is on MSDN, give it a try first.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: C++ File

    i want to ask something i got underline for the word "for"
    here is the normal view of the code for the .dll (only simply .dll file)
    Code:
    // MFS.cpp : Defines the exported functions for the DLL application.
    //
    
    #include "stdafx.h"
    #include <iostream>
    
    /*Бърз и прост начин за заместване на краш команда
    //AntiCrash Prevent
    */
    for(int X=0; X < (int)strlen(Message);X++){
    if(Message[X] == '&#37;'){
    Message[X] = '"';
    }
    }
    In the red i make the word that is underline for me and i got error:
    IntelliSense: expected a declaration

    how to fix it?

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    This is really an unrelated question, but the reason is that your code is not contained within a function. Think about it, when would this code run if it is not contained in a function?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: C++ File

    can you tell me something to make it work, to make some function with this source code so that to work normal, please help

  8. #8
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    That depends completely on what you're wanting to do. Are you saying you don't know how to write a function?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: C++ File

    i had just started learning c++, but 1 friend ask me to make an .dll file with this source code for fixing a problem in one gameserver, thats why i want help to make it

    i tryed something like this but not work (in Red is underline) , please help me to build 1 project then i will try make it by myself i just need expiriance and support
    Code:
    // MFS.cpp : Defines the exported functions for the DLL application.
    //
    
    #include "stdafx.h"
    #include <iostream>
    
    using namespace std;
    /*Бърз и прост начин за заместване на краш команда
    //AntiCrash Prevent
    */
    int main ()
    {
    
    for(int X=0; X < (int)strlen(Message);X++){
    if(Message[X] == '&#37;'){
    Message[X] = '"';
    }
    }
    
    
    return 0;
    }

  10. #10
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    How should this DLL be used? Seeing as you have identified a need for a DLL, you must also have an idea what functions the DLL should provide.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    524

    Re: C++ File

    this .dll should be used by hooking it inside a gameserver.exe (program)

  12. #12
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: C++ File

    ok, what functions does your dll need to provide?

    are you able to provide more information as to what this gameserver.exe is and what your dlls purpose is?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width