Sign in to follow this  

DLLimport kernal32 in C#

This topic is 2389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I try to use:

[code]

[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);
[/code]


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

Share this post


Link to post
Share on other sites
[quote name='LiquidWotter' timestamp='1306963334' post='4818428']
When I try to use:

[code]

[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);
[/code]


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
[/quote]


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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this