Jump to content

  • Log In with Google      Sign In   
  • Create Account

DLLimport kernal32 in C#


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 LiquidWotter   Members   -  Reputation: 100

Like
0Likes
Like

Posted 01 June 2011 - 03:22 PM

When I try to use:


[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernal32")]
private static extern bool QueryPerformanceFrequency(ref
            long PerformanceFrequency);

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernal32")]
private static extern bool QueryPerformaceCounter(ref
            long PerformanceCount);


It throws me a System.dllNotFoundException in my game loop.

I tired to changing it to "kernal32.dll", but that didn't work. I tired a quick search to see if it had anything to do with the fact i'm running 64 bit win7, but I couldn't find anything on that. I have been able to get DLLimport to work in the past with other dll files, I am unsure why it isn't working with this dll.

Any help I can get is greatly appreciated.
LiquidWotter

Sponsor:

#2 doesnotcompute   Members   -  Reputation: 258

Like
1Likes
Like

Posted 01 June 2011 - 04:40 PM

When I try to use:


[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernal32")]
private static extern bool QueryPerformanceFrequency(ref
            long PerformanceFrequency);

[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernal32")]
private static extern bool QueryPerformaceCounter(ref
            long PerformanceCount);


It throws me a System.dllNotFoundException in my game loop.

I tired to changing it to "kernal32.dll", but that didn't work. I tired a quick search to see if it had anything to do with the fact i'm running 64 bit win7, but I couldn't find anything on that. I have been able to get DLLimport to work in the past with other dll files, I am unsure why it isn't working with this dll.

Any help I can get is greatly appreciated.
LiquidWotter



Check your spelling (it's k-e-r-n-e-l not kernal).

EDIT:

Also, you can use the Stopwatch class in System.Diagnostics instead of pinvoking QueryPerformaceCounter.

#3 LiquidWotter   Members   -  Reputation: 100

Like
0Likes
Like

Posted 01 June 2011 - 05:41 PM

Wow I'm such an idiot. That fixed it thanks!

Also thanks for the class suggestion, I knew there had to be an easier way, but I am currently going through a book so I'm doing it the author's way first hehe.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS