I need to know a way to open a notepad document from one of my programs without opening a console window. The calling program is a standard window, so it would look bad if a console widow opened. There are a couple of things you should be aware of as well. I have already tried system("call ..."), which opens the console, and also, I can't include windows.h due to conflicting class names. Please help.
waldchr -2 Junior Poster in Training
Recommended Answers
Jump to PostSo add a new source file to your project called runner.cpp
All this does, is
- include windows.h
- implements a thin wrapper, say myRunner() round say CreateProcess()
- and returnsrunner.h just contains the prototype of myRunner(), which in itself is NOT dependent on windows.h
Include …
Jump to PostMaybe you could try posting your errors.
> Um, unless i'm not doing it right, it still comes up with the same conflicting definitions errors. Here's the code:
That looks for all the world like you just created a new .cpp file, then right away did
#include "runner.cpp"
in …
Jump to PostPlace this function into the separate .cpp file:
void ShowText(const char* filename) { ::ShellExecuteA(::GetDesktopWindow(), "open", "notepad.exe", filename, 0, SW_SHOWNORMAL); }
Include <windows.h> dependency into this file only.
This function works in console applications too.
All 10 Replies
Salem 5,265 Posting Sage
tux4life 2,072 Postaholic
waldchr -2 Junior Poster in Training
tux4life 2,072 Postaholic
tux4life 2,072 Postaholic
Salem 5,265 Posting Sage
waldchr -2 Junior Poster in Training
Salem 5,265 Posting Sage
ArkM 1,090 Postaholic
tux4life commented: Good job! +5
waldchr -2 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.