DLLimport kernal32 in C#

Started by
1 comment, last by LiquidWotter 12 years, 10 months ago
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
Advertisement

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.
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.

This topic is closed to new replies.

Advertisement