|
Start by asking in the correct forum. You are looking for ASP.NET..
|
|
|
|
|
(Just learning C# and trying to do what I did in C++ with C#, and this is not an urgent question)
I have a COM "server" with a method FileOpen which returns a HRESULT :
...
[id(2), helpstring("Open a file.")] HRESULT FileOpen([in] BSTR filename);
...
STDMETHOD(FileOpen)(BSTR filename);
...
When I added the reference to my COM stuff in my sample C# project, the method is listed as Void FileOpen(...) (when I look at the browser in the IDE), I loose the return code.
Am I missing something ? As far as I understand, the COM is wrapped in a proxy (Runtime callable Wrapper) of some kind; I assume this strips the return value from the prototype ?
Thanks for any help, hints, tips, or links (or even better) for google keywords that can help me in my searches.
Max.
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: this is not an urgent question
That makes this a very very good question
Maximilien wrote: the method is listed as Void FileOpen(...) (when I look at the browser in the IDE), I loose the return code.
That is correct. AFAIK, the COM wrapper will check the HRESULT and auto throw the COM Exception, kinda neat, hey? (I could be completely wrong too, hehe)
|
|
|
|
|
That's what I just discovered, and above all, there is a HResult property in the System.Exception
Thanks.
This signature was proudly tested on animals.
|
|
|
|
|
|
baai koel
|
|
|
|
|
ja lekker hehe
|
|
|
|
|
Well I didnt really know, well maybe I did, I have been grinding on .NET for almost 7 years so I cant really recall. Anyways just follow the element of least surprise principle
|
|
|
|
|
I am using StreamWriter to write out some jpeg data in byte[] to a file.
The result of my file is always "System.Byte[]"
byte[] jpegData = new byte[img.Length];
jpegData = Convert.FromBase64String(img);
using (StreamWriter sr1 = new StreamWriter("C:\\123.jpg"))
{
sr1.Write(Convert.ToString(jpegData));
sr1.Flush();
sr1.Close();
}
|
|
|
|
|
Why don't you use BinaryWriter instead?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
System.IO.File.WriteAllBytes()
|
|
|
|
|
Thanks, this worked great.
Do you know how i would write this jpeg data in the form of byte[] to a form instead of to a file? So in other words i would like to display jpg on the form. Would i need a picture control?
|
|
|
|
|
You can simply do:
myform.BackgroundImage = Image.FromStream(new MemoryStream(jpegbytes));
|
|
|
|
|
thanks, i'll try that.
If i would like to put 4 images on the form, i would have to write them to a control write?
|
|
|
|
|
Hello I have one question regading the conversion of Hex String into Decimal number.
Hex Number is in format
“aaaaaa”
This 24-bit field is the direction “A” counter stored LS-byte first.
Example is, take this hex string "100000" which is decimal equivalent is 16
But i don't know how to convert this number into decimal number. If i give this number to C# function it is not giving me the exact 16 equivalent.
Another exanples are
060100= 262
1C0000= 28
Can any body please help me how to convert these numbers into decimal equivalent using C#
Thanks
Shailesh
|
|
|
|
|
int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
Hogan
|
|
|
|
|
Thanks Hogan but i think you did not read the question. It is writing the LS byte first when i use your solution it is giving me 1048576 not 16.
Any body please help me
Thanks in advance
shailesh
|
|
|
|
|
shailesh,
Sorry about that. I usually thing of "LS" as a different model of a car, not part of definition of the problem. I assume LS means "Left Side" then?
Hogan
|
|
|
|
|
snorkie wrote: I assume LS means "Left Side" then?
Close It means Least Significant.
|
|
|
|
|
I felt bad about giving a bad answer, so I wrote a whole program to do this. Hope this helps... Sorry I was too lazy to comment the code.
using System;
using System.Collections.Generic;
using System.Text;
namespace ReverseHex
{
class Program
{
static void Main(string[] args)
{
string hexValue = Console.ReadLine();
int finalNumber = 0;
int multiplyCount = 0;
for (int x = hexValue.Length - 1; x >= 0; x--)
{
int tempAdd = multiplyCount * 15;
switch (hexValue[x])
{
case '1':
finalNumber += tempAdd + 1;
break;
case '2':
finalNumber += tempAdd + 2;
break;
case '3':
finalNumber += tempAdd + 3;
break;
case '4':
finalNumber += tempAdd + 4;
break;
case '5':
finalNumber += tempAdd + 5;
break;
case '6':
finalNumber += tempAdd + 6;
break;
case '7':
finalNumber += tempAdd + 7;
break;
case '8':
finalNumber += tempAdd + 8;
break;
case '9':
finalNumber += tempAdd + 9;
break;
case 'A':
case 'a':
finalNumber += tempAdd + 10;
break;
case 'B':
case 'b':
finalNumber += tempAdd + 11;
break;
case 'C':
case 'c':
finalNumber += tempAdd + 12;
break;
case 'D':
case 'd':
finalNumber += tempAdd + 13;
break;
case 'E':
case 'e':
finalNumber += tempAdd + 14;
break;
case 'F':
case 'f':
finalNumber += tempAdd + 15;
break;
}
multiplyCount++;
}
Console.WriteLine("Int Value:" + finalNumber.ToString());
}
}
}
Hogan
|
|
|
|
|
snorkie wrote: I felt bad about giving a bad answer
Dude, this is a coding horror!
Go improve it now!!! Surely you can spot the pattern
|
|
|
|
|
Its already bad enough that I did his homework for him... I don't want to make it too nice!
Hogan
|
|
|
|
|
|
|
Snorkie
Thanks for the solution but it is not giving me the correct number still.
for Hex string 100000 value should be 16.
060100= 262
1C0000= 28
Any other suggestion please. I am running out of my module time. Please reply.
Thanks
Shailesh
|
|
|
|