|
|
?
|
|
|
|
|
Ravi posted a link which will show you similar examples.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I see But I didn't find any answer to my question there. I need not WinNT with GUI interface, in contrary I need TWO processes. First one is a WinNT service and second one is a GUI program to manage first. Also this interacting should be double sided in order to service was be able to notify GUI program about its state. Sorry if I can mistake but I've really find not answer in topic being advised. Sorry again if I am silly At such case give me exact link please.
Thanks (and sorry) in advance
|
|
|
|
|
Hello Morozov
Well I havent had to write such an application so far. In fact I have never ever written an NT service.
But I might have to, soon.
I'd suggest this, perhaps it's a silly suggestion.
Have an admin port. Say you keep port 20000 open and the GUI client can connect to this port and send commands to the server [runnin as an NT service]. An advantage would be, now your service can be remotely controlled.
You can require authentication for connecting to this port thus making it kinda secure
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
G'Day Morozov
I used this article to get me started when I had to do the very same thing.
http://www.codeproject.com/system/cntservice.asp.
Ended up creating an NT service and a Dialog Application to control the service, modify parameters etc. The above article was a huge help - thanks PJ Naughter
|
|
|
|
|
If you make your service a COM server (which the ATL Wizard can generate), you can then get your client program to interact with the service via COM. I have used this method when both the client and server apps reside on the same machine.
Michael
|
|
|
|
|
|
I use a prog on my own computer called AOL Instant Logger to log all of my AIM messages (not the AOL prog, the AIM prog, just to avoid confusion...). Anyway, does anyone know how one would write a program such as this? I'm not sure how to make one get the data from the AIM application. Any tips would be appreciated.
~Cam (BinaryUprising.com)
|
|
|
|
|
double& Matrix::operator() (unsigned row, unsigned col)
{
if (row >= rows_ ¦¦ col >= cols_)
throw BadIndex("Matrix subscript out of bounds");
return data_[cols_*row + col];
}
double Matrix::operator() (unsigned row, unsigned col) const
{
if (row >= rows_ ¦¦ col >= cols_)
throw BadIndex("const Matrix subscript out of bounds");
return data_[cols_*row + col];
}
what differnce double& and double?
why their implement is same?
can you tell me ?thank in indvance!
|
|
|
|
|
Passing by reference means that any changes to the variable in the function effect the variable that was passed into the function, just like a pointer. Unlike a pointer, a reference is a value, not a memory address.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Ooops - I just saw where the reference is. Yes, because this variable remains in scope, it means that the variable you get back IS the variable in the array, not just the value of that variable.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
The difference is that the first version has a non-const this pointer, so the returned value is a reference to an array value. That means you can change the contents of the Matrix, such as:
void f ( Matrix& m )
{
m(2,5) = 3.14;
} But in the second, this is const, thus the return value cannot reference the object. So this code is illegal:
void g ( const Matrix& m )
{
m(4,1) = 42;
}
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
One function accepts an address of another as a parameter, I want to use a member-function of a class as the parameter, but I have this error: cannot convert parameter 1 from 'void (void)' to 'int (__cdecl *)(void)'
There's an example (MVSC++6) (Compilation gives the error)
typedef void(*fntFunc)();
class CMy
{
public:
CMy(){};
~CMy(){};
void Func();
};
void CMy::Func(){}
void CallIt(fntFunc fn)
{
fn();
}
int main(int argc, char* argv[])
{
CMy my;
CallIt(my.Func);
}
Thanks a lot. http://sjcomp.virtualave.net
|
|
|
|
|
Two issues here:- Your
Func method has to be static if you want to pass it on as a regular function pointer. Check Mike Dunn's C++ FAQ for details.
- Once you hace declared your method static, you can set its calling convention like this:
class CMy{
...
static void __cdecl Func();
};
Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín is right.
A standard solution to this common problem is to have 2 static items: (1) a pointer to a CMy object and (2) a function of the type you expect to pass as a parameter, eg:
static CMy* pMy = NULL;
static void StaticFunc()
{
if (pMy != NULL) {
pMy->Func();
}
} Then, have a CMy object set the static pMy to "this" before you pass StaticFunc() to CallIt(), eg:
CMy my;
pMy = &my;
CallIt (&StaticFunc);
Hope this helps.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
I'm probably stating the obvious here, but my solution is slightly different from Joaquin's in that CMy's member function doesn't have to be static.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
|
Thanks everyone for assistance, it solves the problem as I state it, but the situation I have is like this: I have a function which is predefined and this function takes a callback function as parameter. I'm creating class, each copy of which should have it's own call back function. (I'm using glut (for OpenGL) and I'm creating window class whcih uses glut functions, and I'd like glut call a member-function of the class.)
Let's say I have function
void CallIt( void(*func)(ini,int)) );
And I can not change it.
The problem is that I want to have a couple of classes which are waiting for the callback, and CallIt doesn't provide inforamtion what class set the callback (
And as understood I can use only static functions or global functions and I can use class specific functions to link with CallIt.
I dont' see a way to do it, right now, but hope I'm wrong.
Regards, Alexander.
|
|
|
|
|
Well, the standard solution is to provide a pointer to the class when you register your function (this is usually called a callback parameter): this callback parameter can be used by your static callback function to transfer the function call to the actual class responsible for doing the job.
Unfortunately, GLUT seems not to provide any mechanism to store any callback parameter on callback registration. But do not abandon any hope, there's still a way (if a little convoluted) to retrieve the class, via glutGetWindow() . The idea is having a map associating windows IDs with classes, and having the static method dispatch to the appropriate class using this map. This is s little piece of pseudocode that describes the process using the glutMouseFunc callback:
class MyGlutWindow{
private:
static std::map<int,MyGlutWindow*> ID2MyGlutWindow;
public:
MyGlutWindow(){
...
ID2MyGlutWindow[glutGetWindow()]=this;
}
static void __cdecl glutMouseFuncCallback(int button,int state,int x, int y){
ID2MyGlutWindow[glutGetWindow()]->doGlutMouseFuncCallback(button,state,x,y);
}
void doGlutMouseFuncCallback(int button,int state,int x, int y){
...
}
}; There are some details missing (cleanup when windows are destroyed, for instance), but the basics are here, I hope you get the idea and find it useful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot! It really helps Have not thought about such aproach. Thanks.
Regards, Alexander
|
|
|
|
|
Well I'm no Delphi expert, but I guess the best thing to do is having the array allocated (even statically) on the Delphi client. Just like this:
var
myarray packed array [1..801] of char;
...
begin
...
TheDLLFuntion(...,@(myarray[1]),...);
...
end; where TheDLLFunction accepts a char * (a ^char in Delphi).
As I said before, I'm no expert in Delphi, so forgive me if this is off-topic (or simply incorrect).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Has anybody had problems trying to reply other posts? For some reason I'm not being able and have been forced to post the reply on a new thread.
|
|
|
|
|
Are there API functions available to access a USB port? Just as we have CreateFile() for the serial port?
|
|
|
|
|
I wonder how to check an item in a menu?
(this code in OnInitDialog())
CMenu menu;
menu.LoadMenu(IDR_POPUP);
menu.CheckMenuItem(ID_POPUP_ALLTIDVERST,MF_CHECKED | MF_BYCOMMAND);
Isn't the the menu allready created from start?
Or do I have to overriden some function?
It wont be selected?
The menu is a tray menu...
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
This menu is being created and then destroyed right away. To check or uncheck an item, you need to use the OnCmdUI handler, or you need to check it in OnContextMenu, just before you show it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|