 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Fri Jun 06, 2008 7:10 pm Post subject: C++ help with .dll |
|
|
| Code: | #include <windows.h>
#include "stdafx.h"
DWORD WINAPI Start(){
Sleep(500);
MessageBox( 0, "Hi!", 0, 0 );
Sleep(500);
ExitThread(0);
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)&Start, 0, 0, NULL );
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
} |
I get this eror:
| Code: | | error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' |
Help Please
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Fri Jun 06, 2008 7:25 pm Post subject: |
|
|
Either use a Multi-Byte character set, or use one of the following:
1) WideCharToMultiByte
2) Include tchar.h and use the _T() definition.
3) Either coat the string with TEXT(), or place an L before the start of a string.
http://msdn.microsoft.com/en-us/library/ms776440.aspx
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Fri Jun 06, 2008 7:30 pm Post subject: |
|
|
| Renkokuken wrote: | Either use a Multi-Byte character set, or use one of the following:
1) WideCharToMultiByte
2) Include tchar.h and use the _T() definition.
3) Either coat the string with TEXT(), or place an L before the start of a string.
http://msdn.microsoft.com/en-us/library/ms776440.aspx |
Can you give an example/chage it?
Cause im a newbie at this .dll stuff.
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Fri Jun 06, 2008 7:52 pm Post subject: |
|
|
Sure.
To use a Multi-Byte character set, just right click your solution in the Solution Explorer, click Properties, and under the General tab, change "Character Set" to "Use Multi-Byte character set."
For the others:
1) http://msdn.microsoft.com/en-us/library/ms776420.aspx
2) Personal preference. Have "tchar.h" included in your project, and just coat strings with it's _T() macro.
Error example:
| Code: | | MessageBoxW( 0, "This is a char string", "Hello world!", MB_OK | MB_ICONINFORMATION ); // error C2664 |
Proper usage is as follows:
| Code: | #include <tchar.h>
...
MessageBoxW( 0, _T( "This is a char string" ), _T( "Hello world!" ), MB_OK | MB_ICONINFORMATION ); // No error |
3) Same as above, but instead of _T(), use just TEXT(). As for the L operator...
Example:
| Code: | | MessageBoxW( 0, L"This is a char string", L"Hello world!", MB_OK | MB_ICONINFORMATION ); // No error |
I apologize if there are any typos, it's late and I just woke up ( reversed sleeping habits for the win ). Hope it helps.
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Fri Jun 06, 2008 7:55 pm Post subject: |
|
|
| Renkokuken wrote: | Sure.
To use a Multi-Byte character set, just right click your solution in the Solution Explorer, click Properties, and under the General tab, change "Character Set" to "Use Multi-Byte character set."
For the others:
1) http://msdn.microsoft.com/en-us/library/ms776420.aspx
2) Personal preference. Have "tchar.h" included in your project, and just coat strings with it's _T() macro.
Error example:
| Code: | | MessageBoxW( 0, "This is a char string", "Hello world!", MB_OK | MB_ICONINFORMATION ); // error C2664 |
Proper usage is as follows:
| Code: | #include <tchar.h>
...
MessageBoxW( 0, _T( "This is a char string" ), _T( "Hello world!" ), MB_OK | MB_ICONINFORMATION ); // No error |
3) Same as above, but instead of _T(), use just TEXT(). As for the L operator...
Example:
| Code: | | MessageBoxW( 0, L"This is a char string", L"Hello world!", MB_OK | MB_ICONINFORMATION ); // No error |
I apologize if there are any typos, it's late and I just woke up ( reversed sleeping habits for the win ). Hope it helps. |
You are the best! Thanks for the help
+ rep
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Fri Jun 06, 2008 8:02 pm Post subject: |
|
|
| Glad to help, just ask if you need any more assistance in the future.
|
|
| Back to top |
|
 |
|
|
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
|
|