|
Steve,
Thanks for your reply. But it is not working. I'll explain you once again how I am running these processes. I have write a program where I am executing Process B using shellexecute with out any credentials and Process A with CreateProcessWithLogon API with admin credentials. Now when both processes are running Process A tries to get handle to the Process B and it fails.
The code given above will work only when I am running these two processes indiviually. but not thru any program as I explained.
If you any idea how can one get the handle to the process B when running thru third program / utility.
Thanks
SNI
|
|
|
|
|
I too had problem in opening the process created by another user.I can even open system process but not process created by another user. That problem not solved yet.
|
|
|
|
|
Nave,
Can you tell me how do you achieve this. pls spedify code if possible.
Thanks
SNI
-- modified at 5:53 Wednesday 4th July, 2007
|
|
|
|
|
Hello,
I want to find computers and network shares with in My network places using C++/MFC code.
I can find files and folders using FindFirstFile and FindNextFile but how can I find network shares and computers in work group?
can any one help me please?
Regds
Buddhika
Annasi
|
|
|
|
|
check the NetShareEnum() function in msdn. A sample is also there.
|
|
|
|
|
Hi,
I know how to sort simple int or String based Carrays using qsort but I'd like to sort a CArray that is composed of a class with mixed variable types. Also, I'd like to sort the CArray based on one member of the base class and have the other members maintain their original association, ie.,
class CMyClass : public CObject
{
int m_A;
double m_B;
CString m_C;
}
CArray <cmyclass, cmyclass&=""> MyClassArray;
as an example say the members in MyClassArray are:
m_A, m_B, m_C
2 2.4 HI
1 5.6 BYE
4 8.3 NO
after sorting on the int field the sorted CArray would look like-
m_A, m_B, m_C
1 5.6 BYE
2 2.4 HI
4 8.3 NO
There is an articleon this site, "QuickSort enabled CArray template class" which describes sorting of user defined class members but it appears to sort the column selected independently without reordering the associated elements.
A very "inelegant" way of doing this would be to copy the sort field to a simple CArray, sort it and then locate the elements in the original array that correspond with the sorted elemnts and rebuild the complex array. I'm hoping there is better way.
Thanks
|
|
|
|
|
Try something like this. Note I use STL's collection classes and not MFC's.
----------------------------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
class CMyClass
{
public:
CMyClass(int a, int b)
: m_A(a)
, m_B(b)
{}
int m_A;
double m_B;
};
// Function to sort by 'm_A'.
inline bool MyClassLessByA(const CMyClass &l, const CMyClass &r)
{
return l.m_A < r.m_A;
}
// Function to sort by 'm_B'.
inline bool MyClassLessByB(const CMyClass &l, const CMyClass &r)
{
return l.m_B < r.m_B;
}
// Function to write the class to an output stream.
inline std::ostream& operator<<(std::ostream &os, const CMyClass &cr)
{
os << "CMyClass(" << cr.m_A << ", " << cr.m_B << ")";
return os;
}
int main(int arvc, char* argv[])
{
using namespace std;
// Create an "array" and populate it.
vector<CMyClass> array;
array.push_back(CMyClass(1, 5.0));
array.push_back(CMyClass(2, 4.0));
array.push_back(CMyClass(3, 3.0));
array.push_back(CMyClass(4, 2.0));
array.push_back(CMyClass(5, 1.0));
// Shuffle the array into a random order.
random_shuffle(array.begin(), array.end());
// Output the shuffled array to the console.
cout << "Array before sorting:" << endl;
copy(array.begin(), array.end(), ostream_iterator<CMyClass>(cout, "\n"));
cout << endl;
// Sort by 'm_A'.
sort(array.begin(), array.end(), MyClassLessByA);
// Output the array to the console.
cout << "Sorted by 'm_A':" << endl;
copy(array.begin(), array.end(), ostream_iterator<CMyClass>(cout, "\n"));
cout << endl;
// Sort by 'm_B'.
sort(array.begin(), array.end(), MyClassLessByB);
// Output the array to the console.
cout << "Sorted by 'm_B':" << endl;
copy(array.begin(), array.end(), ostream_iterator<CMyClass>(cout, "\n"));
cout << endl;
return 0;
}
----------------------------------
The output on my system was the following:
Array before sorting:
CMyClass(5, 1)
CMyClass(4, 2)
CMyClass(1, 5)
CMyClass(3, 3)
CMyClass(2, 4)
Sorted by 'm_A':
CMyClass(1, 5)
CMyClass(2, 4)
CMyClass(3, 3)
CMyClass(4, 2)
CMyClass(5, 1)
Sorted by 'm_B':
CMyClass(5, 1)
CMyClass(4, 2)
CMyClass(3, 3)
CMyClass(2, 4)
CMyClass(1, 5)
Steve
|
|
|
|
|
My registered activex control seems to be corrupted or missing. Now before installing new one I want to remove it entirely even from VC++ registered activex control. How Can I remove it.
In similar manner how to remove added activex control in application.Because it gets added to standard controls list. How to remove it. I agree most of time when you add same control it gets overwritten but I dont want that, as I am not sure overwriting may not be correct.
|| Lust Causes Sorrow ||
|
|
|
|
|
Hi
The typeid operator requires run-time type information (RTTI) to be generated, which must be explicitly specified at compile time through a compiler option.
Could i know,how to enable RTTI in VC6.0
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
Its in the compiler option, under the Language category I think
|
|
|
|
|
project->settings->C/C++->Enable Run Time Type Information (RTTI)
|
|
|
|
|
1. Select "Project"->"Settings" from the application's menu.
2. Select the project and configuration.
3. Select the "C/C++" tab.
4. Select "C++ Language" in the "Category" combo.
5. Tick the "Enable Run-Time Type Information (RTTI)" check box.
Steve
|
|
|
|
|
I read "A Fast Bresenham Type Algorithm For Drawing Ellipse" by John Kennedy Mathematics Department.
Below function was developed base on above algorithm.
I want to ask someone help me, how can develop below function to rotate ellipse.
If someone have an other ideals, can you help me!
<br />
void CBGraphics::DrawEllipse(HDC hDC, int x1, int y1, int x2, int y2, COLORREF color)<br />
{<br />
long x, y, XChange, YChange, EllipseError, TwoASquare, TwoBSquare, StoppingX, StoppingY; <br />
TwoASquare = 2 * x2 * x2;<br />
TwoBSquare = 2 * y2 * y2;<br />
x = x2;<br />
y = 0;<br />
XChange = y2 * y2 * (1 - 2 * x2);<br />
YChange = x2 * x2;<br />
EllipseError = 0;<br />
StoppingX = TwoBSquare * x2;<br />
StoppingY = 0;<br />
while( StoppingX >= StoppingY)<br />
{<br />
Put4Pixel(hDC, x1, y1, x, y, color);<br />
y++;<br />
StoppingY += TwoASquare;<br />
EllipseError += YChange;<br />
YChange += TwoASquare;<br />
if( ( 2 * EllipseError + XChange) > 0 )<br />
{<br />
x--;<br />
StoppingX -= TwoBSquare;<br />
EllipseError += XChange;<br />
XChange += TwoBSquare;<br />
}<br />
}<br />
x = 0;<br />
y = y2;<br />
XChange = y2 * y2;<br />
YChange = x2 * x2 * (1 - 2 * y2);<br />
EllipseError = 0;<br />
StoppingX = 0;<br />
StoppingY = TwoASquare * y2;<br />
while (StoppingX <= StoppingY)<br />
{<br />
Put4Pixel(hDC, x1, y1, x, y, color);<br />
x++;<br />
StoppingX += TwoBSquare;<br />
EllipseError += XChange;<br />
XChange += TwoBSquare;<br />
if( (2 * EllipseError + YChange) > 0)<br />
{<br />
y--;<br />
StoppingY -= TwoASquare;<br />
EllipseError += YChange;<br />
YChange += TwoASquare;<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Hi,
This Algorithm is based on 4 point symmetry of ellipse. And when the ellipse is rotated this symmetry will lost at numerous position. This algorithm can be used to increase the speed of plotting ellipse in a raster system for ellipse in its symmetric shape.
The parameters to the function is center and X and Y radius. I strongly think this algorithm cannot be used for plotting ellipse in all ellipse transformation.
|
|
|
|
|
Thanks you for your advice. by the way, Can you give me an other algorithm that you think it's suit to solve my trouble?
|
|
|
|
|
Hi,
i'm making a program that monitors user connection and what that user is doing in my PC. Please let me know how to do this. I'm currently on a LAN connection. I just want to monitor computers are connecting to my PC.;);)
I know this is kindof a general question but i just do not know where to start.
Thanks.
|
|
|
|
|
How about NetConnectionEnum() and NetFileEnum() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
I assume this is only applicable if I'm sharing a resource on my PC. I would also want to monitor those computers that connect on my PC even if I'm not sharing..and, by the way, not only from LAN but also from those that connect to my PC through the internet.
Thank you!
|
|
|
|
|
Is it possible to create a custom vector allocator that allows you to allocate the maximum amount of memory your vector will ever need during vector instantiation, thereby allowing you to avoid dynamic allocation/reallocation/deallocation during program execution? When you add an item to your vector, it uses the available memory. When you remove an item from your vector, it will not delete the memory, it will only clear it and allow it to be re-used.
If this is possible, can someone provide guidance on how to code this, or provide a link where something like this is accomplished or talked about? I have no experience with Allocators, so I apologize if this is a dumb question.
I need to create a sorted list that provides array indexing capability, but also avoids dynamic allocation and deallocation.
|
|
|
|
|
you could use std::vector::reserve to allocate the number of element.
|
|
|
|
|
Thanks for the info.
Let's say I use reserve, and I reserve memory for 5 integers, 1 through 5.
If I call erase() on integer 3, how will this affect the internal memory structure of the vector? Will the vector have an empty space where 3 used to be (e.g. 1,2,-,4,5) or will the remaining elements in the vector get "pushed" over (e.g. 1,2,4,5)?
|
|
|
|
|
If you erase an element from a vector the elements after the deleted element are moved to fill the space. A vector 's memory never gets smaller unless you use the following trick:
vector<int> copy(source);
source.swap(copy);
Steve
|
|
|
|
|
I tried ~WS_THICK_FRAME in precreate window.
Maximize box is disabled but when i double click on title bar it always restores
how to prevent this???
Problem is solved......
I solved using WM_NCLBUTTONDBLCLK any other solution.
|
|
|
|
|
Override OnNcLButtonDblClk().
Manish Rastogi
|
|
|
|
|
I'm new to c++ and this forum, so please...
I want to convert one type(int/float/double, can be 8/16/32/64bits), which is unknow when compiling, to another type, which is also unknow at compile time, in some function. One way is to use a vitual function and override that function with different arugment types. It's a heavy function with a lot of coding, so I want to search some other options.
I'm wondering if there is a solution so that I only need to write one conversion function which can take care of whatever input/output types.
Here are some pseudo codes which I'm not sure if they can be somehow realized. Hope it wouldn't confuse you.
define type T*;
Convert( T* in, T* out)
{
for_each_datum_in
{ *in=(type of out)*out;
}
}
//call the function here
Convert( TypeOfIn * in, TypeOfOut * out);
now here am i
|
|
|
|
|