Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C# & C dll help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Thu Jun 26, 2008 1:19 am    Post subject: C# & C dll help Reply with quote

ok, i have a dll i made in C *yes its basic* and i have a couple questions.

1. Can a program in C# use variables from the C dll? Like, example, use MessageBox.Show in C# to show a variables value from the C dll?

And secondly. I know this is really nooby, but i have having problems with showing a message box in the dll. So when you call its function, it will get the mouse coordinates and display them in a message box. Here is my code:

Code:
#include <stdio.h>
#include <windows.h>

extern "C" {

    void __declspec (dllexport) MouseCoords() {

        POINT coords;
      float x = 0;
      float y = 0;

      GetCursorPos(&coords);

      x = coords.x;
      y = coords.y;

      MessageBox(
         NULL,
         L"X Coordinates: "
         strcat(coords.x));
    }
}



BOOL WINAPI DllMain (HINSTANCE, DWORD, LPVOID) {

    return TRUE;

}



EDIT: and i get these errors:
Quote:
Warning 1 warning C4244: '=' : conversion from 'LONG' to 'float', possible loss of data c:\documents and settings\tyler\desktop\mouse.dll\mouse.dll\mouse.dll.cpp 18


i messed with the code, can't seem to fix it. Embarassed

yea, i know i am a complete noob with messing with strings (using strcat), so don't flame me, i already did it for you guys -_-

Thanks for the help. Embarassed
Back to top
View user's profile Send private message MSN Messenger
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Jun 26, 2008 3:17 am    Post subject: Reply with quote

Warning != Error

and

MessageBox(
NULL,
L"X Coordinates: "
strcat(coords.x));
}

wheres your comma?
besides, strcat doesn't take 1 parameter.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Thu Jun 26, 2008 4:15 am    Post subject: Reply with quote

Make a function that returns your variable and import it.

And can I ask why did you declare "float x,y" if you never used them?
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Thu Jun 26, 2008 1:09 pm    Post subject: Reply with quote

Symbol wrote:
Make a function that returns your variable and import it.

And can I ask why did you declare "float x,y" if you never used them?


because i am going to use them. I will use them once i actually figure out how to add them to the end of the message box Embarassed
Back to top
View user's profile Send private message MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Thu Jun 26, 2008 1:19 pm    Post subject: Reply with quote

Why not just using "coords" instead?
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Thu Jun 26, 2008 1:43 pm    Post subject: Reply with quote

Symbol wrote:
Why not just using "coords" instead?

ok, fine.

But eitherway, i just want to know how to use strcat with a message box. So i can show the value of a variable. This is what i mean (in C#)

Code:
MessageBox.Show("My age is: " + age);


basically just that in C++...
Back to top
View user's profile Send private message MSN Messenger
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Thu Jun 26, 2008 2:20 pm    Post subject: Reply with quote

strcpy(variable, "My age is: ");
strcat(variable, age);

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Jun 26, 2008 5:35 pm    Post subject: Reply with quote

Overload wrote:
Symbol wrote:
Why not just using "coords" instead?

ok, fine.

But eitherway, i just want to know how to use strcat with a message box. So i can show the value of a variable. This is what i mean (in C#)

Code:
MessageBox.Show("My age is: " + age);


basically just that in C++...


Thats VC++. Native C++ is MessageBox(hwnd, "Message", "Title", MB_OK)

_________________
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Jun 26, 2008 6:20 pm    Post subject: Reply with quote

Code:
wsprintf(buf, TEXT("My age is: %d"), age);
MessageBox(0, buf, TEXT("Age!"), 0);
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Jun 26, 2008 6:49 pm    Post subject: Reply with quote

POINT expects long values, not floats.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Jun 26, 2008 8:10 pm    Post subject: Reply with quote

Just a suggestion from MSDN about LocalAlloc:

Quote:
Note The local functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Fri Jun 27, 2008 12:49 am    Post subject: Reply with quote

Flyte wrote:
Code:
wsprintf(buf, TEXT("My age is: %d"), age);
MessageBox(0, buf, TEXT("Age!"), 0);


so for "buf", do i need to allocate mem? like: (char*) malloc(sizeof(buf));

Is that right?
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites