Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I had a simple mathequation that I thought I might speed up using a Win32 DLL but it's returning a different value than in VB (the one that I hoped for). Here's the code in VB (the one that works) and the code in C++ (which returns a bad value):

 

Dim y As Integer = CInt(arY + (((arHeight - crdHeight) / NumCards) * crdNum))

 

//C++ VS 2003
return arY + (((arHeight - crdHeight) / NumCards) * crdNum);

Posted
oh, arY, arHeight and crdHeight are integers in both, and NumCards and crdNum are longs in both. The Function returns an integer
Posted

well the program I use this for does this function about 1 000 times on average per frame.

 

the C++ portion is returning arY, that's it

Posted

Try this, grouping everything may help, I'm not a C++ programmer though so I can't be sure

//C++ VS 2003
return (arY + (((arHeight - crdHeight) / NumCards) * crdNum));

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted

ok, I changed the Function definition to:

 


short _stdcall SetYPosition(long NumCards, long crdNum, int crdHeight, int arHeight, int arY)

//it was:
//short _stdcall SetYPosition(int arY, long NumCards, long crdNum, int crdHeight, int arHeight)

 

now its returning the value of crdHeight every time!

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...