|
I really don't think us writing the code for you is going to help much. We've already helped you with a few conversion, but you're really gonna need to learn how to convert yourself, or use tools that will do the conversion for you. I've already pointed you to Reflector; why not just compile that VB.NET code as a dll (if it's not already), point Reflector at it, and have it generate for you C# code?
Here's a screenshot[^] of Reflector generating C# code from one of my .dll files. As you can see, Reflector generated the C# code for me, even though the dll was written in VB.NET.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
i had it converted on c# on my own without using convertion tools... but i have a problem with this statement when converting it to c#...
vb code ---> bProductKey(ilKeyByte) = Int(nCur / 24)
i tried it on c# code with this code --> bProductKey[ilKeyByte] = (byte)((int)(nCur / 24));
it compiled correctly but it has a different output already......
Im am SUPER P
|
|
|
|
|
Ok, I put your VB.NET code into a VB.NET application, compiled it, pointed Reflector to it, and here's what Reflector had to say:
private string Decrypt_Key(byte[] bProductKey)
{
StringBuilder builder1 = new StringBuilder();
char[] chArray1 = new char[] {
'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X',
'Y', '2', '3', '4', '6', '7', '8', '9'
};
long num1 = 0x18;
do
{
int num3 = 0;
long num2 = 14;
do
{
num3 = (num3 * 0x100) ^ bProductKey[(int) num2];
bProductKey[(int) num2] = (byte) Math.Round(Conversion.Int((double) (((double) num3) / 24)));
num3 = num3 % 0x18;
num2 += -1;
}
while (num2 >= 0);
builder1.Insert(0, chArray1[num3]);
if (((((num1 % ((long) 5)) == 0) && (num1 != 0)) ? 1 : 0) != 0)
{
builder1.Insert(0, "-");
}
num1 += -1;
}
while (num1 >= 0);
return builder1.ToString();
}
I'm telling you, try out Reflector, you'll find it to be a very useful tool.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
i already installed it! And thank you very much!! very useful!! but i encounter a problem with this line
bProductKey[(int) num2] = (byte) Math.Round(Conversion.Int((double) (((double) num3) / 24)));
it says that Convertion does not exists in the current context so i made it to this line
bProductKey[(int) num2] = (byte)Math.Round(Convert.ToInt64(((double)(((double)num3) / 24))));
now it says
Error 4 The call is ambiguous between the following methods or properties: 'System.Math.Round(double)' and 'System.Math.Round(decimal)' C:\Documents and Settings\Paul Villacorta\My Documents\Visual Studio 2005\Projects\practice\practice\Form1.cs 307 52 practice
Im am SUPER P
|
|
|
|
|
Yeah, sometimes reflector doesn't emit perfect code. Maybe try
bProductKey[(int) num2] = (byte) Math.Round(Convert.ToInt32((double) (((double) num3) / 24)));
|
|
|
|
|
Judah Himango wrote: bProductKey[(int) num2] = (byte) Math.Round(Convert.ToInt32((double) (((double) num3) / 24)));
it still has an error.... im trying to figure it out.. but cant determine it... help..
Error 4 The call is ambiguous between the following methods or properties: 'System.Math.Round(double)' and 'System.Math.Round(decimal)' C:\Documents and Settings\Paul Villacorta\My Documents\Visual Studio 2005\Projects\practice\practice\Form1.cs 310 52 practice
Im am SUPER P
|
|
|
|
|
That's because there are several overloads to Math.Round:
double Math.Round(double a, double b);
decimal Math.Round(decimal a, decimal b);
Since a double is implicitly convertible to decimal, it doesn't know which function you're trying to call. There is a trick here though that should solve it: look at the return types. If you get back the return type as double, it should figure out you're trying to use the first one there, since a decimal to double conversion is lossy and therefore has to be done explicitly. So, give this a shot:
double roundedValue = Math.Round(Convert.ToInt32((double) (((double) num3) / 24)));
bProductKey[(int) num2] = (byte) roundedValue;
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Connor's Christmas Spectacular!
Judah Himango
|
|
|
|
|
Judah Himango wrote: double roundedValue = Math.Round(Convert.ToInt32((double) (((double) num3) / 24)));
bProductKey[(int) num2] = (byte) roundedValue;
it doesnt appear to correct.. i tried it already but instead it gives an error of
The call is ambiguous between the following methods or properties: 'System.Math.Round(double)' and 'System.Math.Round(decimal)!
i think its because of the result of num3 / 24 gives a decimal value and thus it cant cast the value to double.... uhhh.. still cant get it...
anyway thanks!!
Im am SUPER P
|
|
|
|
|
|
I am researching a project and am trying to get some direction. I may be tasked with accessing a service that has a existing C API, but I don't do C proper, only C#.
So what I am looking for are recommendations on things I can do or places I can look for support on getting at this API.
Thanks all!
D
You are only as good as your last project.
|
|
|
|
|
|
PInvoke.net will list the functions for Windows API's. For third-party libraries, you'll have to contact the manufacturer of the library you're trying to use.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Kindly I want to know how I can use c# to do the following tasks in LAN:
- send and receive files to another PC(s) in my workgroup
- place an a signature or E-signature to the file which i sent belong to the user
- I want this file to come back to me with the user comment and signatue to be sure that he received it and read it with the comments
- when the user wants to open the sent file he has to put a password to open that file and read it so after putting that password his signature will automatically placed in the document
- the attachments such as Word documents or exel.
thanks for interst
with best regards
imad
|
|
|
|
|
Why not just use email?
|
|
|
|
|
Public Function Get_Reg(ByVal RegPath As String, ByVal RegKey As String, ByVal target As String) As Object
Dim Reg As Microsoft.Win32.RegistryKey
Dim RegMain As Microsoft.Win32.RegistryKey
Try
Reg = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, target)
RegMain = Reg.OpenSubKey("SOFTWARE\" & RegPath)
Return RegMain.GetValue(RegKey, "")
Catch ex As Exception
Return Nothing
Exit Function
End Try
Reg.Close()
Reg = Nothing
End Function
Please convert this to c# code....
Im am SUPER P
|
|
|
|
|
public object Get_Reg(string RegPath, string RegKey, string target) {
Microsoft.Win32.RegistryKey Reg;
Microsoft.Win32.RegistryKey RegMain;
try {
Reg = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, target);
RegMain = Reg.OpenSubKey("SOFTWARE\\" + RegPath);
return RegMain.GetValue(RegKey, "");
}
catch(Exception ex) {
return null;
}
// FOLLOWING CODE WILL NEVER BE EXECUTED!!!
Reg.Close();
Reg = null;
}
___________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA]
|
|
|
|
|
using Microsoft.Win32;
...
public object Get_Reg(string regPath, string regKey, string target)
{
RegistryKey reg = null;
RegistryKey regMain = null;
try
{
reg = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, target);
regMain = reg.OpenSubKey("SOFTWARE\\" + RegPath);
return regMain.GetValue(regKey, string.Empty);
}
catch(Exception ex)
{
return null;
}
finally
{
if(reg != null)
{
reg.Close();
}
}
}
|
|
|
|
|
how about this one.. this one might be difficult....
Private Function Decrypt_Key(ByVal bProductKey() As Byte) As String
Dim ilByte As Long
Dim ilKeyByte As Long
Dim nCur As Integer
Dim RetKey As New System.Text.StringBuilder
Dim bKeyChars() As Char = {"B", "C", "D", "F", "G", "H", "J", "K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9"}
For ilByte = 24 To 0 Step -1
nCur = 0
For ilKeyByte = 14 To 0 Step -1
nCur = nCur * 256 Xor bProductKey(ilKeyByte)
bProductKey(ilKeyByte) = Int(nCur / 24)
nCur = nCur Mod 24
Next ilKeyByte
RetKey.Insert(0, bKeyChars(nCur))
If ilByte Mod 5 = 0 AndAlso ilByte <> 0 Then RetKey.Insert(0, "-")
Next ilByte
Return RetKey.ToString
End Function
Im am SUPER P
|
|
|
|
|
Let me show you my secret weapon: Lutz Reflector[^]. Point it to a dll or exe built in Visual Basic.NET, and it can show you the corresponding code in C#. It's a great tool and will help you with your conversion process.
|
|
|
|
|
Judah Himango wrote: Let me show you my secret weapon: Lutz Reflector[^]. Point it to a dll or exe built in Visual Basic.NET, and it can show you the corresponding code in C#. It's a great tool and will help you with your conversion process.
It says C to VB... does it have a reverse convertion?
Im am SUPER P
|
|
|
|
|
If it says "C to VB" it has to be a typo. Reflector shows compiled code as IL, C#, VB , Delphi, MC++ or Chrome. There is no conversion from one language to another, and there is no C code.
---
b { font-weight: normal; }
-- modified at 12:31 Friday 24th February, 2006
|
|
|
|
|
i think you have sent the wrong converter.. its really a c# to vb converter...
do you have a yahoo messenger?
Im am SUPER P
|
|
|
|
|
It isn't a converter; it is a decompiler that can decompile any .NET code into C#, VB.NET, IL, and a few others. Just load up your dll that you want converted to C#, then view the disassembled code in C#.
|
|
|
|
|
public object Get_Reg(string RegPath, string RegKey, string target) {
Microsoft.Win32.RegistryKey Reg;
Microsoft.Win32.RegistryKey RegMain;
try {
Reg = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, target);
RegMain = Reg.OpenSubKey(("SOFTWARE\\" + RegPath));
return RegMain.GetValue(RegKey, "");
}
catch (Exception ex) {
return null;
// TODO: Exit Function: Warning!!! Need to return the value
return;
}
Reg.Close();
Reg = null;
}
|
|
|
|
|
|