|
I want to transfer files through the Internet via Visual C++. There's no problem with the transaction of the files but if i try to execute these files at the remote site an error occurs. What have i to do during the transaction or else where to get the files running ?
|
|
|
|
|
First:
How you are transfering the files? Do You are using Ftp classes?
Second:
How you are trying to execute the app, in the remote machine, or in your pc but with the file in the remote machine?
Regards!!!
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I guess you will have some kinda small program stub running on the target machine and that you use that to receive the files over there. So all you need to do is add code to ShellExecute the transferred files within that stub.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hello everyone,
I have a modaless CPropertySheet with its name "Control Panel"
I also use the command CWnd::FindWindow(NULL, "Control Panel") to locate the control panel.
Problem came when I just so happen to have the Window's _real_ Control Panel open while running my program. The FindWindow() found the CWnd ptr to the Window's Control Panel. I tried replacing the NULL in FindWindow() with my class name "CControlPanelSheet" which is a inhareted class of CPropertySheet, but FindWindow just returns NULL, and can't find any windows.
Does anyone know what may fix the problem? What is the proper way to retrieve the pointer to a modaless CPropertySheet?
Thank you for your help.
|
|
|
|
|
I tried replacing the NULL in FindWindow() with my class name "CControlPanelSheet"...
This parameter is not the name of the MFC but instead of something
called "Window class" which does not have much to do with your
classes --here it is "DIALOG", I think.
If you want to locate a pointer to the sheet inside the same application, then the best thing you can do is having a global variable that holds that pointer: the same CControlPanelSheet object can set/clear this global variable on construction/destruction, so you always know if the object is alive or not.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
> the same CControlPanelSheet object can set/clear this global variable on construction/destruction...
This is a good idea. Do you mean I can place something in OnSetActive and OnKillActive? I think what you mean is setting that the PropertySheet's own pointer to 0. How can I set its own pointer when I'm within its class? Do you mean sending a message from OnKillActive to the parent window that created the modaless PropertySheet, and have the parent set the pointer to 0 there?
|
|
|
|
|
Well, it is not in OnSetActive and OnKillActive (those would be useful for keeping track of the active property page), but rather on construction and destruction time. To polish things up, you can wrap it all in static methods of your class. Sort of like this: (Warning: I've not even compiled it, expect typos)
class
CControlPanelSheet{
...
static CControlPanelSheet* GetActiveSheet()
{
return theOne;
}
static BOOL CreateSheet(...){
if(theOne)return FALSE;
new CControlPanelSheet();
return TRUE;
}
...
private:
static CControlPanelSheet theOne;
CControlPanelSheet(...)
{
...
theOne=this;
}
~CControlPanelSheet()
{
theOne=NULL;
}
void afx_msg OnDestroy()
{
CPropertySheet::OnDestroy();
delete this;
}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ah, this is a really engenious way of doing things. Keeping a static variable to keep track of its own pointer. Very smart. Thank you Joaquín.
|
|
|
|
|
BTW, it's not "DIALOG". But good guess though.
I like your pointer idea. If you can get back to me explaining more of that, I'd appreciate it. Thanks Joaquín.
|
|
|
|
|
What is it then?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I don't know... I don't think there is one.
I believe the class name exists in CDialog. CDialog has a create that takes
-- Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
Where I think the 1st argument is what FindWindow looks for. However, I fail to find a simular thing in CPropertySheet.
|
|
|
|
|
I'm afraid that class name has nothing to do with any template: indeed, the class name for dialogs is "DIALOG" (and for buttons is "BUTTON", for texts is "STATIC").
To find out, you just have to investigate any property sheet with a small program called Spy++ that comes as part of your Visual Studio. I happen not to have this program handy right now.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have functions that both "delete" two buffer allocated by "new." This has to be done because the functions can be used in different ways. I was just wondering is there a way to know if the memory has already been deleted and so don't do it again?
|
|
|
|
|
After you've deleted the memory, set the pointer to NULL. Before you try to delete again, check to see if the pointer is NULL.
Michael
|
|
|
|
|
After you delete the buffers, set their pointers to NULL. Then, to see if the buffers currently point to any memory, you can test their pointers against NULL.
Jon Sagara
What about ?
"Teve Torbes, I've only got one thing to say to you: Tuck Off!" -- Dob Bole
|
|
|
|
|
If single threaded use this:
----------------------------
extern char * buf;
void func1(){
if (buf) { delete buf;buf == NULL;}
}
void func2(){
if (buf) { delete buf;buf = NULL;}
}
If multi threaded use this :
----------------------------
extern char * buf;
extern CRITICAL_SECTION cs1;
void func1(){
EnterCriticalSection(&cs1);
if (buf) { delete buf;buf=NULL; }
LeaveCriticalSection(&cs1);
}
// same for func2
// see MSDN for use of CriticalSection
|
|
|
|
|
I am trying to call a DLL function from InstallShield but the setup always give me an error "DLL Function
call crashed".
The DLL is loaded successfully and the function is called as well but what happens after that is my
big problem!
My DLL is built using MFC Wizard, I defined the exported DLL in .DEF
Please help me, what wrong did I do? May be I should create the DLL in another way!?
|
|
|
|
|
It is hard to say without having more info. One wild guess: have you tried declaring your function with the WINAPI specifier?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
No, I did not use WINAPI. Now after I used it, the problem was solved but I have another error message: "DLL function call resulted in bad stack. Possible incorrect prototyping".
The function declaration in the DLL is:
long WINAPI CApp::SetFunction()
The prototype declaration in InstallShield is:
Prototype stdcall long MyDll.SetFunction();
I tried using the other declaration:
Prototype cdecl long MyDll.SetFunction();
What should I do?! Thank you for you help.
|
|
|
|
|
Is by chance your function non-static ?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
If you can afford declaring it as static , I think that'd solve the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If i decalre my function as static, then i cannot export it, then the InstallShield will not be able to find my function and read it. I guess my problem is when the value is returned to InstallShield. Can you please explain to me more why you suggested the static function? may be i am missing a something here?
|
|
|
|
|
If I'm not wrong, your function is not a stand alone function, but rather a member function of a class of yours named CApp . Then, declaring it as static does not have the same meaning as with a stand alone function, it merely says that this member function can be called without bounding to any instance of CApp . Try modifying your .h like this:
class CApp{
...
static long WINAPI SetFunction();
...); and do not make any other change: this should fix the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes, my function is not a stand alone function, it is a member function of a class. I tried to declare it the way you told me but it didn't work either
I am thinking that may be i built the DLL in a wrong way? My DLL was built using MFC App Wizard (Dynamic DLL). Can you advice me if what I did is wrong or what type of DLL I should use?
Thank you.
|
|
|
|