|
Here is c++ code, want to do same in c#:
COleVariant va;
BYTE *pSrc;
va = m_object.GetMethod();
HGLOBAL h = (HGLOBAL)va.lVal;
pSrc = (BYTE*)GlobalLock(h);
|
|
|
|
|
Hello World !
I want to call(run) my default dial_up connection with C#...
how can this ...
TanX world ...
if(Human.live)
{
Human.peaceful = false;
while(true)
{
Human.love(Human girl, Human Boy);
}
}
|
|
|
|
|
Hello everyone,
My application runs under low privilege account like NetWork Service, but in some specific method I need to have high privilege (e.g. to write to registry or access some local file).
So, I want to change the user privilege of some specific method of a class. Does anyone have any good ideas how to do this in .Net?
thanks in advance,
George
|
|
|
|
|
George_George wrote: Does anyone have any good ideas how to do this in .Net?
Yes.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Do you mean impersonate?
I have investigated impersonate technologies and it looks good. But two more issues with
impersonate technogies.
http://www.codeproject.com/KB/cs/zetaimpersonator.aspx
- How to manage the password expire issue? (for example, in the current domain, the
policy is for every 6 months, password must be changed);
- Is it possible to impersonate from a high privilege to a low privilege user without
providing password? My concern is to hardcode password in source code.
regards,
George
|
|
|
|
|
George_George wrote: How to manage the password expire issue?
How are you dealing with it on the account the process starts under?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry Mark!
I do not know what do you mean "dealing with it on the account the process starts under" -- could you say some other words please?
regards,
George
|
|
|
|
|
I have investigated impersonate technologies and it looks good. But two more issues with
impersonate technogies.
http://www.codeproject.com/KB/cs/zetaimpersonator.aspx
- How to manage the password expire issue? (for example, in the current domain, the
policy is for every 6 months, password must be changed);
- Is it possible to impersonate from a high privilege to a low privilege user without
providing password? My concern is to hardcode password in source code.
regards,
George
|
|
|
|
|
I may be wrong, but I don't think a running application can (nor should) elevate its privileges beyond that of the currently logged in user.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
I don't care if you *can* or not, I'm saying you shouldn't. User privileges are established for a reason.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks John,
Are there any technologies which I could use to impersonate? Thanks again!
regards,
George
|
|
|
|
|
|
Thanks Le Centriste,
I like this comprehensive document. But it does not answer my question. My question is about how to change user privilege in a special method, i.e. impersonate. Do you have any good ideas for solution?
This document you recommended does not answer my question.
regards,
George
|
|
|
|
|
I know this may sound like a stupid question, but my head is completely empty today.
I have three group boxes whose contents all differ greatly but only one of the three is displayed at any point in time. This leads to my question, does disabling and making not visible free up the memory from a group boxes contents or is there another method which should be used?
Cheers
|
|
|
|
|
As long as the form is alive, and unless you specifically dispose/null the controls, they will always consume the memory they need.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you, I will have to think about this one for a little bit and assess the best way to structure the program so there is not things sat in memory unused for long periods of time.
|
|
|
|
|
It's actually best to allocate them early and leave them in memory if possible, especially if they could potentially be used semi-frequently. Unless the group controls contain child controls that get data from a list or array, you should be okay. Concentrate on other parts of the program instead.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I am using the following code to replace the word "hello" with "hi"
if (strData.ToLower().Trim().Contains("hello there"))
{
strData = "hi there"
}
Question:
How do i modify the above code so that it also consides upper as well as lower characters.
So in the above example, I might have "Hello There" and not "hello there"
Thanks
|
|
|
|
|
In your example, you don't need to because you have lowered the string, so it's not possible to have an upper case in the comparison.
|
|
|
|
|
|
Your statements already handle the capitalization issue. Howevere they don't satisfy the stated requirement (i.e. you're not substituting 'hello' with 'hi' in input string).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Normally, when you make dll-calls from C# you include something like this:
[DllImport("MyDLL.dll")]
However, I want something like this:
[DllImport(new System.IO.MemoryStream(new byte[] { ....} )) ]
Obviously, the above doesn't compile, but is there a workaround that lets me load the dll from a memorystream?
|
|
|
|
|
You could possibly write the DLL stream to a known temporary location, and have DllImport look at that location. DllImport doesn't get bound in anyway, so it is entirely feasible to have the DLL injected at the last minute.
|
|
|
|
|