|
Hi All,
Ok, this should be easy to figure out, but I can't seem to google a good answer. I need a way to programmatically discover the path to the current user's desktop. Something similar to GetWindowsDirectory() or GetSystemDirectory(), I guess.
The only think I could find was VBScript stuff like WshShell.SpecialFolders(...) or using the Windows Shell COM stuff.
There must be a simpler way to do this in C++, no?
TIA,
Pete
|
|
|
|
|
How about SHGetFolderPath(..., CSIDL_DESKTOPDIRECTORY, ...) ?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
That'd do it!
Thanks David
|
|
|
|
|
I have a xml file that I need to copy to a folder near the $(TargetDir)
the custom build "Command Line" looks like this :
mkdir $(TargetDir)\..\MyFolder
copy $(ProjectDir)\myFile.xml $(TargetDir)\..\MyFolder\
and the "Output Line"
$(TargetDir)\..\MyFolder\myFile.xml
The problem is that everytime I execute ( F5 ) my program from VS.net, it asks me to "rebuild" that one file.
I understand that if a file is modified it should be compiled ( in my case copied ), but that file has not been modified for a couple of days.
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I want to write a spy program that will catch all messages of a window that I will choose... I want my program to return the ID's of the edit boxes, buttons, etc... Maybe anyone knows where I can start?
Thanks in advance!
Have a nice day!
|
|
|
|
|
Do you mean something like the Spy++ utility?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Help! I'm using MS Vis Studio 6 (with Vis C++ 6) and I don't really know where to begin. Does anyone know how I might make a simple script that would retrieve any given webpage (by inputting the URL) as some sort of string--like a CString, for instance. I am also behind a proxy, so I'm hoping that either whatever commands you give me automatically adjust to proxy settings or the code takes it into account (e.g. a place for inputting the proxy's IP and Port). Any advice is welcome. Thanks!
|
|
|
|
|
|
Hello,
I have a problem with my code that follows, everything works aye okay until I´m shutting the application down. My desktop resolution is then being set back to 1024x768x16 60Hz, and I have no idea why.
I´m aware that it´s quite alot of text to go through, but I would highly appreciate any suggestions on what might be wrong.
Edit:
The problem does not occur when I erase my ProcessIdle() function.
How come?
Thanks!
<br />
#include <iostream><br />
#include <windows.h><br />
#include <ddraw.h><br />
<br />
#include "resource.h"<br />
using namespace std;<br />
<br />
const char CLASS_NAME[] = "game_proj";<br />
const char WINDOW_NAME[] = "game_proj";<br />
<br />
const int ResX = 1024;<br />
const int ResY = 768;<br />
const int iColor = 32;<br />
<br />
HINSTANCE g_hInst = NULL;<br />
HWND g_hWnd = NULL;<br />
LPDIRECTDRAW7 g_pDD = NULL;<br />
<br />
LPDIRECTDRAWSURFACE7 g_lpDDSPrimary;<br />
LPDIRECTDRAWSURFACE7 g_lpDDSBack;<br />
<br />
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam,<br />
LPARAM lParam);<br />
BOOL InitiateWindow();<br />
BOOL InitiateDD();<br />
void ProcessIdle();<br />
void CleanUp();<br />
<br />
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int iCmdShow)<br />
{<br />
HWND hWnd;<br />
MSG msg;<br />
<br />
g_hInst = hInstance;<br />
InitiateWindow();<br />
<br />
hWnd = CreateWindow(CLASS_NAME,<br />
WINDOW_NAME,<br />
WS_POPUP,<br />
CW_USEDEFAULT,<br />
CW_USEDEFAULT,<br />
GetSystemMetrics(SM_CXSCREEN),<br />
GetSystemMetrics(SM_CYSCREEN),<br />
NULL,<br />
NULL,<br />
g_hInst,<br />
NULL);<br />
<br />
if(!hWnd)<br />
return 0;<br />
<br />
g_hWnd = hWnd;<br />
if(InitiateDD() < 0)<br />
{<br />
CleanUp();<br />
return 0;<br />
}<br />
<br />
ShowWindow(hWnd, iCmdShow);<br />
UpdateWindow(hWnd);<br />
<br />
while(true)<br />
{<br />
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
{<br />
if(msg.message == WM_QUIT)<br />
break;<br />
<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
else ProcessIdle();<br />
}<br />
<br />
return msg.wParam;<br />
}<br />
<br />
BOOL InitiateWindow()<br />
{<br />
WNDCLASSEX WndClass;<br />
<br />
WndClass.cbClsExtra = 0;<br />
WndClass.cbSize = sizeof(WndClass);<br />
WndClass.cbWndExtra = NULL;<br />
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);<br />
WndClass.hCursor = LoadCursor(g_hInst, IDC_ARROW);<br />
WndClass.hIcon = LoadIcon(g_hInst, IDI_APPLICATION);<br />
WndClass.hIconSm = LoadIcon(g_hInst, IDI_APPLICATION);<br />
WndClass.hInstance = g_hInst;<br />
WndClass.lpfnWndProc = WndProc;<br />
WndClass.lpszClassName = CLASS_NAME;<br />
WndClass.lpszMenuName = NULL;<br />
WndClass.style = CS_HREDRAW|CS_VREDRAW;<br />
<br />
return RegisterClassEx(&WndClass);<br />
}<br />
<br />
BOOL InitiateDD()<br />
{<br />
DDSURFACEDESC2 ddsd;<br />
DDSCAPS2 ddscaps;<br />
<br />
int ddrval = DirectDrawCreateEx(NULL, (VOID**)&g_pDD, IID_IDirectDraw7,<br />
NULL);<br />
<br />
if(ddrval != DD_OK)<br />
return -1;<br />
<br />
ddrval = g_pDD->SetCooperativeLevel(g_hWnd, DDSCL_EXCLUSIVE|<br />
DDSCL_FULLSCREEN);<br />
<br />
if(ddrval != DD_OK)<br />
return -2;<br />
<br />
ddrval = g_pDD->SetDisplayMode(1024, 768, 32, 0, 0);<br />
<br />
if(ddrval != DD_OK)<br />
return -3;<br />
<br />
ZeroMemory(&ddsd, sizeof(ddsd));<br />
ddsd.dwSize = sizeof(ddsd);<br />
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;<br />
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |<br />
DDSCAPS_COMPLEX;<br />
ddsd.dwBackBufferCount = 1;<br />
<br />
ddrval = g_pDD->CreateSurface(&ddsd, &g_lpDDSPrimary, NULL);<br />
<br />
if(ddrval != DD_OK)<br />
return -4;<br />
<br />
ZeroMemory(&ddscaps, sizeof(ddscaps));<br />
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;<br />
ddrval = g_lpDDSPrimary->GetAttachedSurface(&ddscaps, &g_lpDDSBack);<br />
<br />
if(ddrval != DD_OK)<br />
return -5;<br />
<br />
return true;<br />
}<br />
<br />
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam,<br />
LPARAM lParam)<br />
{<br />
HDC hdc;<br />
PAINTSTRUCT ps;<br />
<br />
switch(iMsg)<br />
{<br />
case WM_PAINT:<br />
{<br />
hdc = BeginPaint(hWnd, &ps);<br />
EndPaint(hWnd, &ps);<br />
}<br />
break;<br />
case WM_QUIT:<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
}<br />
<br />
return DefWindowProc(hWnd, iMsg, wParam, lParam);<br />
}<br />
<br />
void ProcessIdle()<br />
{<br />
HBITMAP hbm;<br />
HDC hdc;<br />
HDC hdc_bmp;<br />
<br />
g_lpDDSPrimary->GetDC(&hdc);<br />
hdc_bmp = CreateCompatibleDC(NULL);<br />
<br />
hbm = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));<br />
SelectObject(hdc_bmp,hbm);<br />
BitBlt(hdc,0,0,72,72,hdc_bmp,0,0,SRCCOPY);<br />
}<br />
<br />
void CleanUp()<br />
{<br />
if(g_lpDDSBack)<br />
g_lpDDSBack->Release();<br />
if(g_lpDDSPrimary)<br />
g_lpDDSPrimary->Release();<br />
if(g_pDD)<br />
g_pDD->Release();<br />
}
|
|
|
|
|
Feels good to answer myself
well, the problem is solved, all I had to do was to put DestroyWindow(hWnd) UnregisterClass(CLASS_NAME, hInstance) in the end of WinMain().
humpa humpa
|
|
|
|
|
How to execute a EXE remotely from machine
example1)
EXE1 is available in machine1 and
Exe2 is available in machine2
start of exe2 should start exe1
Can u please help on this?
for thendral
|
|
|
|
|
there would be a security problem
you can install a server on machine1 which starts exe1 while running exe2 on machine2. in this case you have to connect to machine1, receive the request and then start exe2
|
|
|
|
|
Who can help ?
I must change the document template for hunderts of Word Documents
Here my code:
_WordDocument doc;<br />
WordDocuments docs;<br />
WordTemplate doc_template;<br />
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);<br />
COleVariant vtFalse((short)FALSE);<br />
COleVariant vtTrue((short)TRUE);<br />
CString str;<br />
_Dialogs dia;<br />
_Dialog di;<br />
LONG lver;<br />
WordTemplate tem;<br />
<br />
app.SetVisible(TRUE);<br />
<br />
docs = app.GetDocuments();<br />
doc = docs.Open(COleVariant(csFileName), <br />
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,<br />
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional,<br />
vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);<br />
<br />
dia = app.GetDialogs();<br />
di = dia.Item(87);
<br />
di.GetProperty(0, 0???, &str); ????
all works fine, but I can't access the name of the template.
Any Ideas.
Thx
|
|
|
|
|
having trouble reading what i have written in binary. i do beleive it is writing correctly (because there is a binary value in the text file it creates) but having trouble getting the binary value back into an array of 0's and 1's that i can look at.
well, the code i has seems to give me back all 1's no matter what.
please, if anyone knows about binary i/o!
thank you
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void main()
{
char textbit[8];
ifstream textfile;
textfile.open("bin.txt");
ofstream binaryfile ("realbin.bin", ios::out|ios::binary|ios::ate);
for (int i = 0; i < 8; i++) //get the 8 bytes from the plain text file
textbit[i] = textfile.get();
textfile.close();
for (int i = 0; i < 8; i++) //output them to screen
cout<
|
|
|
|
|
ok well i guess i got the i/o working
but now im kind of stuck
where i have
for (int x =0; x <2; x++)
that runs the loop 2 times and loads 2 8bit values into the binary file.
but i want this loop to run for the length of the input file.
whats the easy way to do that?
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void main()
{
char rtextbit[8];
char binarybyte =0; //chars are 8 bits 0 means 00000000
char textbit[8];
ifstream textfile;
textfile.open("bin.txt");
ofstream binaryfile ("realbin.txt", ios::out|ios::binary);
for (int x =0; x <2; x++)
{
for (int i = 0; i < 8; i++) //get the 8 bytes from the plain text file
textbit[i] = textfile.get();
cout<
|
|
|
|
|
Hi Group
Can anybody help me in rgds to Writing a code for Remote Shutdown using Pipes in VC++
Thanks in Advance
VC++
|
|
|
|
|
Hello,
I am using Windows 2000 Professional and VC++ 6.0 (MFC).
I have created a simple dialog based application.
I want to run this application when I click "Shut Down" from start menu.
How to achieve this?
TIA,
Regards,
Jahfer V P
|
|
|
|
|
You would need a separate application running that handles the WM_QUERYENDSESSION message. When that message is received, return 0, start the "dialog based application."
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
But, would the os allow launching a process when its in the process of shutdown? I think you have to abort the shutdown first, launch your application and call ExitWindows(...) again.
____________________________________________________________
rishabhs
I think therefore I am.
|
|
|
|
|
r i s h a b h s wrote:
I think you have to abort the shutdown first, launch your application...
Which is exactly what I suggested.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
HI,
I am using ActiveX ( formula 1 Control grid .. same as Excel) , as i enter value ( 1/1/2004 etc in the cell. the ActiveX grid take it as a date and convert it in a numeric value ( i think ) , but when i get beck the Value from that cell it returns me the Interger( numeric) value.
How can i get that values back same as in 1/1/2004 format
Because i want to print it in same format.
other then this date format all integer and String values are working fine
thanks
Regards.
|
|
|
|
|
Hi,
I use a none MFC based Dialogbox, and I dont get an accelerator to run.
Here are my codesnippets:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow)) return FALSE;
if((hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_STEALTHDIALOG)) == 0)
error(0, "Cant load Accelereators!");
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)||
!IsDialogMessage(msg.hwnd,&msg) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
Now: I created a new Accelerator, with the same ID as a button, cause they should do the same.
IDC_STEALTHDIALOG ACCELERATORS MOVEABLE PURE
BEGIN
"S", BTN_CONNECT, VIRTKEY, ALT, NOINVERT
END
I see that something happens to the button, it gets the focus, and theres no peep like when I press another combination than Alt+s.
But nothing happens. No action for the button. I also changed the ID of the accelerator, and put some code to its WM message, same result.
Whats wrong?
DKT
|
|
|
|
|
Hi
I am a 13 year old newbie to C++ and I really want to learn it. I already know HTML, XHTML, CSS and the basics of PHP. I already have a set of video tutorials but I need to know some stuff about c++ first.
1) What can you do with it (e.g. create programs, create webpages, etc)?
2) What is an IDE?
3) Are there any free C++ compilers out there (like Microsoft Visual C++)?
Thanks a lot
Rob
|
|
|
|
|
Also, is there anything else I need to know before learning it?
Thanks a lot guys.
|
|
|
|
|
Rob_BCFC wrote:
1) What can you do with it (e.g. create programs, create webpages, etc)?
A better question might be "What can you not do with it?"
Rob_BCFC wrote:
2) What is an IDE?
Integrated Development Environment. It's the editor, compiler, and linker all rolled into one.
Rob_BCFC wrote:
3) Are there any free C++ compilers out there (like Microsoft Visual C++)?
Yes.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|