Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   need to create a DLL in VS.NET to use in Borland C++ (https://thetfp.com/tfp/tilted-technology/96280-need-create-dll-vs-net-use-borland-c.html)

yatzr 10-18-2005 06:57 AM

need to create a DLL in VS.NET to use in Borland C++
 
I have some code for a random number generator written in VB.NET. It makes a few microsoft exclusive calls as well. I need to implement it in Borland C++ Builder, and I was told the easiest way to do it would be to make a DLL in VS.NET and use it in the Borland program. I have very little experience with VS.NET and no experience using DLL's so any help to get me going is greatly appreciated.


I guess the other route I can take though is to figure out how to implement it directly in borland. The exclusive calls are:

Dim rng As New RNGCryptoServiceProvider
rng.GetBytes(someByteArray)
..... I don't understand what the GetBytes does
Dim sha512 As New SHA512Managed
sha512.ComputeHash(someOtherByteArray)

if anyone knows some borland equivalents for those, that would work too. Thanks

BAMF 10-18-2005 02:45 PM

When I write DLLs in c# (using .net) to use in Excel macros I need to set the COM interprated (I know this is wrong, but the COm part is right) to TRUE when I compile. Its is kindof hard to find the option to set this.

hrdwareguy 10-19-2005 09:22 AM

Not pretty but it would work:

In your C++ Builder, call the executable VS code. Have the VS code write the output to a file. Then read the output file in C++ Builder and delete the temp file.

Leviathan[NCV] 10-20-2005 03:12 PM

Quote:

Originally Posted by hrdwareguy
Not pretty but it would work:

In your C++ Builder, call the executable VS code. Have the VS code write the output to a file. Then read the output file in C++ Builder and delete the temp file.

Actually, no it wouldn't.


The only option for you here is to use a CCW (com callable wrapper) and then use com inside of your borland C++ app. There's no good way to call managed code from an umanaged program.

yatzr 10-20-2005 04:20 PM

i'm thinking it would just be easier to try to do it in borland directly now. here's the original code, it looks simple enough there's got to be a way to do it in borland


Dim i As Integer
Dim PerfCtr(3) As Byte
Dim OutCtr As Long
Dim FinalArray() As Byte
Dim CtrOK As Boolean
Dim BC As BitConverter
Dim Rand64(63) As Byte
Dim rng As New RNGCryptoServiceProvider

For i = 0 To 500

' A call to Performance Counter produces a 32 bit word OutCtr
' There are rare instances where the hardware vendor botches support for a high performance counter
CtrOK = QueryPerformanceCounter(OutCtr)
If Not CtrOK Then Throw New System.Exception("Flaky system, try again- use new hardware if it continues")

' Turn the 32 bits into 4 bytes and place in byte array PerfCtr
PerfCtr = BC.GetBytes(OutCtr)

FinalArray = ArrayConcat(FinalArray, PerfCtr)

rng.GetBytes(Rand64)

FinalArray = ArrayConcat(FinalArray, Rand64)

Next

' Hash the stuff

Dim FinalHash() As Byte
Dim sha512 As New SHA512Managed

FinalHash = sha512.ComputeHash(FinalArray)

sha512.Clear()


All times are GMT -8. The time now is 02:38 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73