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 


How do i Import in MSVC++ (C) ? __declspec( dllimport )

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Sep 26, 2008 3:56 am    Post subject: How do i Import in MSVC++ (C) ? __declspec( dllimport ) Reply with quote

Is this correct ? cause i can\\\'t get it to work:

Code:
#define DllImport __declspec( dllimport )

DllImport void WINAPI GetPhysicallyInstalledSystemMemory(
   __out  PULONGLONG TotalMemoryInKilobytes
   );


and btw, Dark Byte why does my application crash when i use GetPhysicallyInstalledSystemMemory in Delphi ?

this is what i did:

Code:
type
 PULONGLONG = ^ULONGLONG;

procedure GetPhysicallyInstalledSystemMemory(kbAmount: PULONGLONG); external kernel32 name \\\'GetPhysicallyInstalledSystemMemory\\\';

  ULONGLONG = UInt64;
  {$EXTERNALSYM ULONGLONG}
  ULARGE_INTEGER = record
    case Integer of
    0: (
      LowPart: DWORD;
      HighPart: DWORD);
    1: (
      QuadPart: LONGLONG);
  end;

kb: PULONGLONG;

GetPhysicallyInstalledSystemMemory(@kb);
//ShowMessageFmt(\\\'Total Physicaly RAM: %d\\\', [kb]);
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Fri Sep 26, 2008 9:00 am    Post subject: Reply with quote

Code:
#pragma comment( lib, "libname.lib" )


do you have the lib file?
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Sep 26, 2008 11:29 am    Post subject: Reply with quote

[quote=\"noz3001\"]
Code:
#pragma comment( lib, \"libname.lib\" )


do you have the lib file?[/quote]

ohh... thanks noz, so that\'s how you import in C/++ ?

cause in delphi it\'s different, thanks a lot nathan, noz\'s the leetness !.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Sep 26, 2008 2:31 pm    Post subject: Reply with quote

How are you introducing backslashes into shit you copy and paste even?

Client Requires Windows Vista SP1.
Server Requires Windows Server 2008.
Header Declared in Winbase.h; include Windows.h.
Library Use Kernel32.lib.
DLL Requires Kernel32.dll.

Just make sure you have windows.h included, and are linking against kernel32.lib. Call it as usual. And of course, you have to meet those requirements (as well as anyone that runs it)
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Sep 26, 2008 4:36 pm    Post subject: Reply with quote

slovach wrote:
How are you introducing backslashes into shit you copy and paste even?

Client Requires Windows Vista SP1.
Server Requires Windows Server 2008.
Header Declared in Winbase.h; include Windows.h.
Library Use Kernel32.lib.
DLL Requires Kernel32.dll.

Just make sure you have windows.h included, and are linking against kernel32.lib. Call it as usual. And of course, you have to meet those requirements (as well as anyone that runs it)


i was using proxies, sorry that causes the /// issue.

and i know it's for Vista SP1 only, just wanna see if it works lol.

and can i see a code snippet on how to import ? cause i know how to export only =/ (bummer)..
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Sep 26, 2008 5:41 pm    Post subject: Reply with quote

You're over-complicating this.

include windows.h...
#include <windows.h>

then just link against kernel32, set it in the linker options or just do it like (you're probably already linking against it by default to begin with):
#pragma comment(lib, "kernel32.lib")

Then just call it.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Sep 26, 2008 6:16 pm    Post subject: Reply with quote

import is for loading custom dlls in your project (apart from Loadlibrary)
export is for exporting (making custom dlls).

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sat Sep 27, 2008 4:37 am    Post subject: Reply with quote

slovach wrote:
You're over-complicating this.

include windows.h...
#include <windows.h>

then just link against kernel32, set it in the linker options or just do it like (you're probably already linking against it by default to begin with):
#pragma comment(lib, "kernel32.lib")

Then just call it.


it won't work, weird!

Code:
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "kernel32.lib")

void main(void)
{
   ULONGLONG kbRAM;
   GetPhysicallyInstalledSystemMemory(&kbRAM);
   printf("Total Physical Ram: %li\n", kbRAM);
}
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Sep 27, 2008 11:22 am    Post subject: Reply with quote

use int main

Look at it under the debugger, what is it returning?
Back to top
View user's profile Send private message
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