|
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.
|
|
|
|
|
|
I have been trying to achive a smooth horizontal scrolling text on the bottom of the screen in one of my applications.
It seems to be almost impossible to get it to run without choppy movements.
My scroller is double buffered, and using microsecond accurate timing to calculate the distance to move pr frame. Still it seems to be moving at a variable rate stuttering on its way from the right to left side of the screen...
I have searched for several days now for examples/techniques how to achive smooth scrolling text, but all the examples I have tried which claims to be smooth scrolling isn't... (Most just implement double buffering, but that only removes flicker).
Some sites suggest sub pixel accure rendering, antialiasing, and that these problems are related to how lcd screens work. I have tried regular GUI programming in C# (graphics/bitmap drawing), DirectDraw (C++ and C#), Direct3D (C++ and C#), and OpenGL (C++).
It's kind of frustrating that something that was possible to do on a Commodore 64 with 1 MHz is so hard to replicate on a 2 GHz modern PC. I guess it goes a long way to show the usefullness of custom chips to help the CPU.
If anyone have some suggestions or even better example code on how to achive such a thing I would appriciate it a lot! (Preferably I would like to run this without a 3D accelerated graphics card.)
|
|
|
|
|
If you can't get it working using one of Microsoft's Direct X libraries you're doing something wrong. It is definitely the way to go...
Create a panel or any kind of container. Create a 3D Device which renders on that object, and create a render loop, which renders and scrolls your text.
|
|
|
|
|
I was struggling with the same issue, but just got it working smoothly with DirectX and C# using the source here:
http://directx4vb.vbgamer.com/DirectX4VB/TUT_DX9Start.asp[^]
You do have to change/upgrade the DrawText() statements a little bit; add null as first param, remove the rect (just use x & y) and textFormat.
Use a scrollPos variable for the X pos.
Can we finally get rid of our C64
|
|
|
|
|
For some videocards (f.e. GeForce 8600GT) it is neccessary to set the PresentParameters.PresentationInterval to PresentInterval.One to get it V-Synced. The Device.Present() method seems to waits for the vertical blanking interval now (and adapts to the vertical refresh rate of your videocard).
PresentInterval: The relationship between the adapter refresh rate and the rate at which Present() operations are completed.
Hope this helps anyone out there!
|
|
|
|
|
Are you really using microsecond accurate timing? The fixed-step timing in Entanglar works pretty well and is very accurate over long periods - but it certainly varys. GDI should have no problems handling this. The debug renderer for Entanglar uses GDI, which is pretty crappy, but I have no worries getting smooth animation out of it.
Make sure you have switched the correct extra styles in your panel constructor as well:
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
Also take a hard look at your timing code and make sure you really understand what is going on. Post the core part of your timing code if you like...
|
|
|
|
|
Here is the code from my attempt in C# with GDI.
private void timer1_Tick_1(object sender, EventArgs e)
{
stopWatch.Stop();
distance = speed * (float)(stopWatch.Elapsed.TotalMilliseconds);
position -= distance; if (position < -300.0f) position = 500.0f;
stopWatch.Reset();
stopWatch.Start();
g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);
g.DrawString("This is a test... This is a test...", new Font("Arial", 30), Brushes.Black, position, 15.0f);
outGfx.DrawImageUnscaled(bmp, 0, 0);
}
Note1: Using System.Diagnostics Stopwatch which features elapsed time in milliseconds and fractions of a millsecond.
Note2: the speed variable is fixed at 0.1f
Note3: The timer is running at 1 ms interval.
Note4: My memory bitmap (bmp) is 500x100
|
|
|
|
|
Regarding Note3, the timer won't be raising events at anything close to a 1ms interval. The scheduling quanta of the kernel is something like 50ms on XP. If the timer you are using raises events on the form's message loop then the accuracy will be even worse. If it uses the thread pool, then you will likely hit some horrible concurrency issues.
Keep it simple for a start. Set your timer to around 100ms. Call Control.Invalidate from the timer event. Hook/override OnPaint for the control. Use DateTime.Now to handle positioning for your animation. That should be more than accurate enough for your needs.
|
|
|
|
|
It won't move very smooth with just 10 updates pr second.
Anyways I moved it all to a thread (with a 5 ms sleep), and call invalidate from the thread, and overide the paint method.
The result is the same, it still doesnt appear to be moving smooth, and the graphics do flicker a bit even when I use
double buffering.
If anyone would like to test my code I have packed the test project (VS2008): http://www.codeinvaders.com/code/ScrollTest.zip
|
|
|
|
|
As I mentioned, you can't sleep a thread for 5ms. If the kernel gives a timeslice to another thread, then it will give a fullquanta, which is around 50ms on XP.
Take the simple example:
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
startTime = DateTime.Now;<br />
g = Graphics.FromImage(bmp);<br />
g.Clear(Color.White);<br />
this.Invalidate();<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
position = (float) (((DateTime.Now - startTime).TotalSeconds * 100f) % 800f) - 300f;<br />
Draw();<br />
this.Invalidate();<br />
}
This runs smooth as hell. You don't need to play with fancy timers to get smooth animation. The reason Entanglar uses a rather complicated phase-locked-loop setup is to minimise drift over a long time (which is fairly critical for stable multiplayer).
|
|
|
|
|
string strType = "hello"
ApplyCleansingRulesFurther(out strType, strIssued);
private void ApplyCleansingRulesFurther(out string strType, string strIssued)
{
////????
if (strType.ToLower().Trim().Contains("hello there"))
////????
{
if (strIssued.ToLower().Trim().Contains("yes"))
{
strType = strType.Replace("hello there", "Hello There!");
}
}
}
--the above code does not compile.
error is on where I placed ????
It says use of unassigned out parameter strType
Thanks
|
|
|
|
|
out parameters mean that they do not have to be instantiated, so your choice is either to instantiate it in the method, or change the type to a ref parameter.
|
|
|
|