|
Wrong - there is only 1 scope operator, but there may be 0 or more namespaces or classes, so that without a modifier, the instance refers to the global namespace, i.e. all publically decared functions as might be declared within your own programme or any libraries linked to your programme.
|
|
|
|
|
What's the command to start a program from within my program?
|
|
|
|
|
use WinExec() function
ex :
WinExec("C:\\Path\\program.exe",0);<br />
"Go as far as you can see,and when you get there you’ll see further" - Unknown
|
|
|
|
|
I guess that's what I was looking for, but it doesn't go all the way. For example, I'd like to be able to close my program and have the other one still running. (When attempting this, the window of the other program also didn't become visible.)
|
|
|
|
|
Anonymous wrote:
but it doesn't go all the way
Have you tried ShellExecute?
Artificial intelligence is no match for natural
stupidity.
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
Anonymous wrote:
I'd like to be able to close my program and have the other one still running
CreateProcess will Help in this case, When you use CreateProcess to Execute a Executable, one of it's parameter i.e. LPPROCESS_INFORMATION parameter return with PROCESSID .
Using that Parameter you can control that process i.e.
For terminating the Process :- [TerminateProcess() ]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
From MSDN:
WinExec is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.
Or alternatively, use ShellExecute, which is a "simpler" function call than CreateProcess.
The StartPage Randomizer
|
|
|
|
|
This code will open a program, open a url, open a file, really open anything that has an associated File Type in the registry and Windows knows what to do with it...and it doesn't matter whether you close your program or not. I only call it OpenURL because that is what I mostly use the function for
BOOL CGlobals::OpenURL(CString csURL)
{
SHELLEXECUTEINFO UrlInfo;
memset(&UrlInfo, 0, sizeof(SHELLEXECUTEINFO));
UrlInfo.cbSize = sizeof(SHELLEXECUTEINFO);
UrlInfo.lpFile = (LPCTSTR)csURL;
// TRUE = explorer/netscape window opened (doesn't check for url connection)
return ShellExecuteEx(&UrlInfo);
}
|
|
|
|
|
// Here's a start:
// Run an external command, optionally waiting around
// for it to finish.
bool RunProgram(LPCTSTR progName, LPCTSTR args,
bool wait /*=false*/, int show /*=SW_SHOWNORMAL*/,
)
{
CString commandLine, userName;
PROCESS_INFORMATION procInfo;
STARTUPINFO startInfo;
memset(&startInfo, 0, sizeof(startInfo));
startInfo.cb = sizeof(startInfo);
startInfo.wShowWindow = (WORD)show;
startInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_FORCEONFEEDBACK;
try
{
// remove leading and trailing spaces
// Trim() is left as an excercise for the reader
commandLine = Trim(progName);
// If there's a space and no double quotes,
// surround the command with double quotes
if (commandLine.Find(' ') >= 0 && commandLine.Find('"') < 0)
commandLine = '"' + commandLine + '"';
commandLine += ' ';
commandLine += args;
LPTSTR lpCommandLine = commandLine.GetBuffer(CommandLine.GetLength() + 32);
if (!CreateProcess(NULL, lpCommandLine, NULL, NULL,
FALSE, 0, NULL, NULL, &startInfo, &procInfo))
return false;
if (wait)
WaitForSingleObject(procInfo.hProcess, INFINITE);
CloseHandle(procInfo.hThread);
CloseHandle(procInfo.hProcess);
}
catch(CMemoryException *)
{
return false;
}
return true;
}
|
|
|
|
|
Hi all,
I need to programmatically enumerate all ODBC drivers installed on a machine. I found some samples, and they work well enough, however I can't find an awful lot of "official" Microsoft documentation on the ODBC APIs themselves.
For example, one of the samples I found uses an API called SQLDrivers(). No problem, it's defined in the latest Platform SDK in sqlext.h. Looking this up in the January 2005 edition of the MSDN library, I'm brought to Servers and Enterprise Development|SQL Server|SQL Server 2000|SDK Documentation|Building SQL Server Applications|ODBC and SQL Server|SQL Server ODBC Driver Programmer's Reference|ODBC API Implementation Details|SQLDrivers, which simply states:
"The ODBC Driver Manager returns all ODBC 3.0-defined SQLDrivers attribute specification strings. For more information about attribute string and value definition, see the ODBC 3.0 documentation."
I'm looking for the actual MS documentation that goes over all the parameters, value returned, possible errors, etc. Where the hell is this??
|
|
|
|
|
I don't think I can help a lot, but maybe you should be looking at SQLBrowseConnect
|
|
|
|
|
> I don't think I can help a lot, but maybe you should be looking at SQLBrowseConnect
I think you misunderstood my question...I don't have any problem enumerating ODBC drivers, per se, but rather I was trying to look for parameter/return value documentation for those SQL*() set of APIs. The section of the MSDN documentation I was looking at essentially describes what the functions do, but do not go into any amount of detail as to what the parameters are, the values returned, error conditions, etc.
For the record, I did find what I was looking for by doing an actual search
It's all under (again, MSDN Library Jan 2005) Win32 and COM Development|Data Access and Storage|Microosft ODBC|Microsoft ODBC|ODBC Programmer's Reference|Part 4 - API Reference|ODBC API Reference.
The funny thing is that with the documentation tree structure opened on both locations, I can see all the same functions being listed twice. Why MS can't organize this better is beyond me...
|
|
|
|
|
Hi,
I'm trying to create a Tooltip control to display tooltip without specifying the hwnd property. Is this possible?
I tried to add a tool to the Tooltip control by specifying the .hwnd property in the TOOLINFO structure as NULL but it doesn't work.
Is it possible in general to display tooltip for application that does not have a Handle?
I read the following post but I don't really understand it as it is in VB:
http://www.codecomments.com/Visual_Basic_Controls/message486687.html
Thanks much - Josh
|
|
|
|
|
Where will your tooltip appear, if you're running a program that doesn't have a window ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
All I want to do is to terminate an application from another application, I can do this by sending wm_close message using postmessage API.
A parameter which postmessage needs is handle to target window this can be found by findwindow, which requires two parameters, window class name or titlebar text. I can't specify title because the title bar text in the target application is not constant. so the only option is window class name.
How can I get window class name of another application, (sdi/mdi), OR
Since the target application is also developed by me how can I set windclss name in that application so that I use same in the terminator applcation.
|
|
|
|
|
Using Spy++? Did you try that utility? It comes free with Visual Studio.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
If you know the location of the other program (XProgram's full path) it's much simpler then that. If you don't know the location..and technically this is the best method rather then hardcoding it in, have the other program write a "ThisIsXProgramsFilePath" registry entry in the InitInstance function (or somewhere that gets hit when XProgram is starting) that the controlling program can read (use a common registry folder...generally your business name). Then use this code from the program that wants control of XProgram:
CString csProgramsFilePath = ...get this from the registry as mentioned above
CWinProcessList process;
DWORD dwProcessID = 0;
DWORD dwProgramID = 0;
if(process.GetProcessInfo(csProgramsFilePath, dwProcessID, dwProgramID))
{
HANDLE hProg = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwProcessID);
if(hProg)
{
if(AfxMessageBox("I'm going to close this program...you OK with that?", MB_YESNO) == IDYES)
{
if(TerminateProcess(hProg, 0))
{
// The program is terminated
}
}
}
else // We failed to get a handle to the program
}
else // The program is most likely not running...or somehow we failed
|
|
|
|
|
pc_dev wrote:
Since the target application is also developed by me
If target application is developeved by you, then it's very easy to find that window, JUST have a look at [RegisterWindowMessage ] api. you will get answer to your question!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi,
i need a program which works with out an installer and can change a file's accessed time. Please help soon.
MFG
RedDragon
|
|
|
|
|
Take a look at SetFileTime function. It will change the time that a file was accessed.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
I am trying to use a CStatic control to allow custom drawing.
Here is the setup. There is a sound library called Bass that has add-ons that allow things such as in my case using Sonique visuals.
To use it you have to amongst other things call the following:
BOOL BASSVISDEF(BASS_SONIQUEVIS_Render)(HVIS handle, DWORD channel, HDC canvas);
I may be going at this all wrong but I am trying to pass this function an HDC to a CStatic control.
CStatic VisWindow; // control variable
<br />
HDC hdc = HDC(VisWindow.GetDC());<br />
BASS_SONIQUEVIS_Render( vischan, chan, hdc);<br />
VisWindow.ReleaseDC((CDC*)hdc);
This is the only way I can get it to compile. Any sugguestions?
|
|
|
|
|
smesser wrote:
This is the only way I can get it to compile. Any sugguestions?
Any suggestions for what? Did you get it to compile or not?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Yes, it compiles but there is another problem.
The C++ interface to the dll I am trying to use is broken at the moment so I can only compile and not link and run.
It just seems I jumped too many hoops for this to work correctly.
The delphi implementation ( provided by author of dll) is really simple.
BASS_SONIQUE_Render( vischan, chan, PaintBox1.Canvas.Handle );
I was thinking that my approach was overly difficult.
|
|
|
|
|
smesser wrote:
...I can only compile and not link and run.
So what's the linker error?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
seem the .lib file that the dll author is not C++ compliant.
First the header file for the dll contains these functions:
void BASSVISDEF(BASS_SONIQUEVIS_CreateFakeSoniqueWnd);
void BASSVISDEF(BASS_SONIQUEVIS_DestroyFakeSoniqueWnd);
They Yield the following error and warnings:
c:\BassVisMFC\BassVisMFC\BassVis.h(49): warning C4229: anachronism used : modifiers on data are ignored
c:\BassVisMFC\BassVisMFC\BassVis.h(49): error C2182: 'BASS_SONIQUEVIS_CreateFakeSoniqueWnd' : illegal use of type 'void'
c:\BassVisMFC\BassVisMFC\BassVis.h(50): warning C4229: anachronism used : modifiers on data are ignored
c:\BassVisMFC\BassVisMFC\BassVis.h(50): error C2182: 'BASS_SONIQUEVIS_DestroyFakeSoniqueWnd' : illegal use of type 'void'
If I comment out from the header those offending lines since I don't seem to need them anyways I then get this linking error.
bass_vis.lib : warning LNK4003: invalid library format; library ignored
|
|
|
|