|
man, I am so sorry I goofed on retval
its the return value
like number = MyClass.Number;
retval is what is returned by number, sorry dude
{retval,out] is the returned type and [out] is just a pointer or whatever like buffer size on str functions
like [out] int *pVal is the pointer to your int you created before the call
int mine;
like number = MyClass.Number(&mine);
its been a while for c code but that should be right
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
humm... so, what is it. Return value is always S_OK/S_FAIL (HRESULT)??
[propget,id(3),helpstring("property ComputerName")] HRESULT ComputerName([out,retval] BSTR *pVal );
I my client code:
CCATLSimpleClass * pSysInfo = new CCATLSimpleClass;
try
{
//So, here, it's "return" value (and it did worked on my machine, by the way, what if there're more than one "retval"?):
String* sComputerName = pSysInfo->GetComputerNameA();
//Compile error: "...error C2660: 'pkATLSimpleASM::CCATLSimpleClass::GetComputerNameA' : function does not take 1 parameters"
pSysInfo->GetComputerNameA(sComputerName);
}
catch(Exception * e)
{
//.NET dont do HRESULT, return S_OK,E_MYERROR..etc will be packaged into an Exception object.
}
Checking dll with ILDASM,
instance string marshal( bstr) GetComputerNameA() runtime managed internalcall
Compare to source code, it seems tlbimp changes signature of the member function:
STDMETHODIMP CCATLSimple::GetComputerName(BSTR* sComputerName)
{
// TODO: Add your implementation code here
USES_CONVERSION;
if(!sComputerName)
return E_POINTER;
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
TCHAR sTemp[MAX_COMPUTERNAME_LENGTH +1];
if(!::GetComputerName(sTemp, &dwSize) )
return E_FAIL;
* (sComputerName) = T2BSTR(sTemp);
return S_OK;
}
Now, what if there're more than one [out/retval]? Which one will be treated as "return"?
norm
|
|
|
|
|
norm wrote:
String* sComputerName = pSysInfo->GetComputerNameA();
do this String* sComputerName = pSysInfo->GetComputerNameA;
that should solve that issue
I don't see how you could have more than one. I mean you can only return one value not multiple. If there is one tell me what library its in so I can investigate it.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
well the return value is 2 things
you must always return an HRESULT because this tells the com service of a pass fail situation which is not used by you but internally.
the retval is what you return like in c#
HRESULT MyProperty( BSTR *pVal )
{
pVAL = TCHAR("dude");
return S_OK;
}
returns dud to your program
return successful to the com service
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Okay so yeah I should have read a little first.
But,
I need to draw circles in a bitmap, but I want to do values instead.
For instance, instead of an array and storing terrain levels 0 to x number I figured it would be much faster to record a bitmap image the size of the map. Then drawing circles on top and every point that they overlay I would add that value +1.
Any pointers, code examples not required.
Nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Has anybody been working with patterns in C#. I would like some book recommondations?
/Ervar
|
|
|
|
|
hi.
I don't know whether this book is good or not, but recently I came over it (the title) on the web.
"Introduction to Design Patterns in C#"
Copyright © 2002 by James W. Cooper
IBM T J Watson Research Center
February 1, 2002
greetings
andi
|
|
|
|
|
Not that great. Definately not a "God" book.
|
|
|
|
|
Thanks, I'll keep looking...
/Ervar
|
|
|
|
|
|
I have looked through the System.Drawing namespace in search for a method that takes a part of a bitmap. But I can't seem to find any.
Grateful for any help offered
|
|
|
|
|
1) Create a new bitmap the size of the area you want to cut out
2) Make a Graphics for that bitmap
3) Use DrawImage to draw the image at the correct location
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Actually I personally think it would be faster to use the close method and let the CLR amanage creating the new image for yoiu which would be inherently faster.
Although I'm a direct3D programmer so the speed would only be noticed by me.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
oki, thx
|
|
|
|
|
hi !
does anybody know which of these two methods to synchronize an ArrayList is more efficient?
execute critical code in a lock block:
lock(myArrayList)
{
blabla
}
-or-
define the ArrayList as Syncronized:
myArrayList = ArrayList.Synchronized(unsyncrArrayList);
thanks.
andi
|
|
|
|
|
Andi
There's no difference performance-wise. (Synchronized uses the lock keyword itself.) Sop it boils down to whether you need to specify the actual intent in your code. With
lock(MyArrayList) {
MyArrayList.This();
MyArrayList.That();
MyArrayList.TheOther();
}
you are explicitly stating that, yes, this is threadsafe. Look, there's the lock keyword. With
MyArrayList.This();
MyArrayList.That();
MyArrayList.TheOther();
you are saying, trust me, I've set up MyArrayList to be a Synchronized version of another ArrayList, so this is threadsafe. Maybe the code that sets up the Synchronized version is nearby, so it's obvious (say in a using block).
Of course, if you forget to set up MyArrayList in that way, you've got a bug.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
hi !
i have the following problem:
i have -lets say- 3 procedures, which should be called at a given probability:
60 % proc. A
30 % proc. B
10 % proc. C
how can i manage this?
my idea:
r = new Random();
if (r.NextDouble() < 0.6) -> A
if (r.NextDouble() >=0.6 and < 0.9) -> B
if (r.NextDouble() >=0.9 and < 1.0) -> C
in principle this works fine, BUT
is this efficient?
is it exact?
what about the pseudo-random-number-generator in c#?
do you have any suggestions ?!?!?!
THANK YOU !
|
|
|
|
|
It does not work, it has a bug. They way you coded, there will be times where no procedure will be called because you are calling r.NextDouble several times. What you need is to store the number on a local variable, like this:
r = new Random();
double d = r.NextDouble();
if (d < 0.6) -- A
if (d >=0.6 and < 0.9) -- B
if (d >=0.9 and < 1.0) -- C
I hope that you have money because it’s necessary to be practical.
And I hope that at least once a year you put some money in front of you and say "you are mine" just to make clear who owns who. - Victor Hugo
|
|
|
|
|
of course !!!!!
thanks.
|
|
|
|
|
You no with putting some web.config file including below lines:
<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>
in some folder, access to that folder is only possible for authenticated users. but this happens only for *.aspx files.
How could we restrict access to for example *.zip files?
|
|
|
|
|
This administrative part, not developer business , simply you have to do it from your windows.
Mazy
No sig. available now.
|
|
|
|
|
hi,
in my app., i have a window form with several labels and groupboxes but no button. i can receive keypress event of that form in my event handler.
however, after added a button the window form, i can't receive KeyPress Event. after deleted it or added another label, it work again!
any help?
thanks,
jim
|
|
|
|
|
hi !
you have to set the KeyPreview-Property of the form to true.
cu
andi
|
|
|
|
|
you also have to
public override bool ProcessKeyPreview( Message msg) {return bProcessed;}
false = did not handle
true = did handle
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
protected override bool ...
Hi,
AW
|
|
|
|