Results 1 to 12 of 12

Thread: Text from dll

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2018
    Posts
    38

    Text from dll

    Hi all.

    It is possible, to read text (label text maybe) from dll.

    So i have a Main program, what is read "texts" from .dll.

    I tryed so:

    dll file:
    Code:
    Public Class dll_text
    
        Public x_user As New String = "test name 1"
        Public x2_user As New String = "test name 2"
    
    End Class
    Main program
    Code:
    Imports dll_text
    
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Label1.Text = Label1.Text = dll_text.x_user          /*but it cant call to string, and dont work
    
    
        End Sub
    End Class
    Thx for the help
    Last edited by dday9; Mar 10th, 2021 at 09:18 AM. Reason: formatted code

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,332

    Re: Text from dll

    It sounds like you are trying to inject a DLL into another process. May I ask what you want to accomplish? Also please use code tags, these can inserted into your post using the toolbar above the message you're about to post. (specifically the "#" button.)

    If you are not trying to inject a dll as I am guessing, could you try to better describe what you want your code to do?

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2018
    Posts
    38

    Re: Text from dll

    I have a main program, ingame overlay for users.

    I wanna make a dll, what is included the user name(s), and the program read this user name from dll. If someone uses the program, whos name is not in dll, he/she can use the main program. I dont wanna change always the main program for this (add new names/players), so i thinked with a little dll (names) i can handle this problem.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,332

    Re: Text from dll

    Why would you want to store names in a DLL? Why would you need to change the code each time someone else plays your game? What does your game do with the names?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,657

    Re: Text from dll

    In that case it doesn't sound like a DLL is an appropriate solution.

    Changing a DLL is almost identical to changing the main program, and this extra work to link the two is just adding extra effort.

    It would be better to use some kind of data file, possibly something text based (most likely XML, as that is easier from code) or something more complex so that it can't be edited by users (you could even make a screen in your program to allow users to edit it if you want).

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,252

    Re: Text from dll

    I'm not going to beat a dead horse, Peter and Si are dead on the money in posts #4 and #5.

    But something to keep in mind is that you should really turn Option Strict on. For more information, I will shamelessly plug my own website: https://www.vblessons.com/lessons.html#/1/2

    The reason I bring this up is because of this line:
    Code:
    Label1.Text = Label1.Text = dll_text.x_user
    I don't know if you're aware or not, but what this is actually doing is setting the Text property of Label1 to the result of the equality check between Label1.Text and dll_text.x_user. This is essentially doing the same thing as:
    Code:
    If (Label1.Text = dll_text.x_user) Then
        Label1.Text = "True"
    Else
        Label1.Text = "False
    End If

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2018
    Posts
    38

    Re: Text from dll

    Label1.Text = Label1.Text =

    it was only copy/paste mistake



    i dont wanna text file, because they can edit it.

  8. #8
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,252

    Re: Text from dll

    You do not need a text file either.

    What you're probably after is My.Settings: https://docs.microsoft.com/en-us/dot...ettings-object

    From the solution explorer, double-click on your project name to open the project's properties. Then from the settings tab, create a setting and set it to your desired value. Finally from code, you can do:
    Code:
    Label1.Text = My.Settings.TheSettingName ' change TheSettingName with whatever name you used

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2018
    Posts
    38

    Re: Text from dll

    Thx, i try it

  10. #10

    Thread Starter
    Member
    Join Date
    Nov 2018
    Posts
    38

    Re: Text from dll

    Label1.Text = My.Resources.sd

    works, thx good idea

  11. #11
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,252

    Re: Text from dll

    Not quite what I suggested, but I suppose it works all the same.

  12. #12
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    624

    Re: Text from dll

    Quote Originally Posted by Olwynn View Post
    Label1.Text = Label1.Text =

    it was only copy/paste mistake



    i dont wanna text file, because they can edit it.
    you can hash the data so they can't modify the file
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

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