|
Fascinating - in some of my code, I used:
SetFilePointer( hFile,
0,
NULL,
FILE_END);
i.e. I have FILE_END and 0 reversed - this also works fine.
I wonder how often you can swap parameters in an API call!
|
|
|
|
|
|
This means I'd have to open the file using CreateFile(). I'm using CFile::Open() to open the file so is there a way to do it this way? I need to create a report that needs to follow a specific format and I'm writing to the file as I go through each set of data. Does CFile not have a function that takes you to the end of the file in order to append the data or some kind of access rights that allow appending?
|
|
|
|
|
I'm tring to find a way to lookup a particular path in the DFS tree to find where the actual resource from what points to it.
I can't seem to find any API calls or objects which deal with this. The simple way is to pipe 'dfscmd.exe /view \\server\dfsshare /batch | grep path_feaure | awk '{print $4}'' and parse that output but it is ugly and I have to install dfscmd, grep and awk on each machine that needs this code.
Does anyone know where I can find some way to do lookups in a DFS tree programatically?
I know i can use NetShareGetInfo to find out if a path is a DFS root but that's as close as I've come (with a hour of google and msdn searches).
Any points in a relevant direction would be extremely helpful.
|
|
|
|
|
Sorry this post is from me and by DFS tree I mean (D)istributed (F)ile (S)ystem [not Depth First Search].
I forgot to login before I posted the message.
My apologies.
Sean
|
|
|
|
|
The article here is really great:
http://www.codeproject.com/listctrl/listeditor.asp
When I run the project and click on an edit box, the box
with focus looks like:
_ _
|________________|
The top part of the box is open and it looks funny. Any
chance any came across this and knows how to make it look
like a full box? Please, any response any one can give
me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
How about posting the question at the messageboard underneath the article you mentioned? At least, it has more relevancies.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I'm working on a frontend to an old dos program, and am at the point where i need to interact with the backend.
I was planning on using the System() call, but was wondering if there's a better way to interface with other programs. For instance, i'd like to know if the backend dos program is still running, or if the program has crashed.
Does VC++ provide a method to do this?
Thanks,
Mike
"I bet Einstein turned himself all sorts of colors before he invented the light bulb." -- Homer J.
|
|
|
|
|
Here is an example nicked from MSDN:
#include <windows.h>
#include <stdio.h>
#define MAXNAMELEN 255
#define CMDLINE "/c dir"
#define IMAGENAME "\\nt\\bin\\cmd.exe"
#define WINTITLE "CreateProcess DEMO"
main(){
BOOL fSuccess,fExit;
DWORD dwExitCode,dw;
STARTUPINFO SI;
PROCESS_INFORMATION pi;
HANDLE hProcess,hThread;
SI.cb =sizeof(STARTUPINFO); SI.lpReserved = NULL;SI.lpDesktop=NULL;
SI.lpTitle="CreateProcess DEMO";SI.cbReserved2=0;SI.lpReserved2=NULL;
fSuccess = CreateProcess((LPTSTR)IMAGENAME, (LPTSTR)CMDLINE,
(LPSECURITY_ATTRIBUTES)NULL,
(LPSECURITY_ATTRIBUTES)NULL,
(BOOL)TRUE,(DWORD)0,NULL,NULL,
(LPSTARTUPINFO)&SI,(LPPROCESS_INFORMATION)&pi);
if (fSuccess) {
hProcess = pi.hProcess; hThread = pi.hThread;
printf("Process Id = %d\nThread Id = %d\n",pi.dwProcessId,pi.dwThreadId);
dw = WaitForSingleObject(hProcess, INFINITE) ;
if (dw != 0xFFFFFFFF) {
fExit = GetExitCodeProcess(hProcess, &dwExitCode) ;
}
CloseHandle(hThread) ; CloseHandle(hProcess) ;
printf("COMPLETED!\n");
}
else printf("Failed to CreateProcess\n");
}
The same method can be used in a GUI-app as well.
|
|
|
|
|
perfect. thanks a million.
Mike
"I bet Einstein turned himself all sorts of colors before he invented the light bulb." -- Homer J.
|
|
|
|
|
Hey, I'm having a problem figuring out how to interpret strings as packed binary data in C++ like you can in Python (see http://www.python.org/doc/current/lib/module-struct.html)
I'm not sure how to go about this, but I need to get the file size and checksum from a file to be able to read separate files from a file package (I'm designing an extractor for it).
This is how you do it in python:
(size,chksum) = unpack(">ii", size_chksum)
size_chksum is 8 bits, the first 4 being the size, and the second 4 being the checksum, it splits it into the variables size and chksum.
This is what one person told me to do in C++, where size is the 4 bits (checksum not used here):
size_int = size[3] << 8 | size[2] << 16 | size[1] << 24 | size[0];
Anyone got an idea???
-NizZy
|
|
|
|
|
LOL
I meant bytes, not bits!
hehe
|
|
|
|
|
Hello All, I'm writing client/server programs using named pipe.
In the server program,
when the user click on a button, it create a thread. Inside a thread function, CreatePipe is called first then listen to client.
Here the code how server program creates the pipe and the thread function
<br />
UINT theThreadFunction(LPVOID lParam)<br />
{<br />
ServerApp *s = (ServerApp*)lParam;<br />
s->CreatePipe();<br />
while(!stop)<br />
{<br />
s->CommunicateWithClient();<br />
}<br />
}<br />
<br />
void ServerApp::CreatePipe()<br />
{<br />
CString temp = "\\\\.\\pipe\\Server"; <br />
LPCTSTR lpszPipename = (const char*) temp;<br />
<br />
hPipe = CreateNamedPipe( <br />
lpszPipename,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE |
PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES,
BUFSIZE,
BUFSIZE,
NMPWAIT_USE_DEFAULT_WAIT,
NULL);
if (hPipe == INVALID_HANDLE_VALUE) <br />
{<br />
MessageBox("CreatePipe failed"); <br />
enableDlgItems = true; <br />
return ;<br />
} <br />
}<br />
<br />
void ServerApp::CommunicateWithClient()<br />
{<br />
...<br />
bool fConnected = ConnectNamedPipe(hPipe, NULL);
...<br />
}<br />
The client application get executed before the Server Application gets executed.
The client used the following code.
<br />
bool ClientApp::ConnectToServer( HANDLE &hPipe)<br />
{<br />
LPCTSTR lpszPipename = "\\\\serverComputerName\\pipe\\Server";<br />
bool connected = false;<br />
hPipe = CreateFile( <br />
lpszPipename,
GENERIC_READ |
GENERIC_WRITE, <br />
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hPipe != INVALID_HANDLE_VALUE) <br />
{<br />
connected = true;<br />
break; <br />
}<br />
return connected;<br />
}<br />
Here the problem, the ServerApp CreateNamedPipe() and then called ConnectNamedPipe(). If there isn't a client connect to the same pipe, the ConnectNamedPipe() waits until a client get connected.
The client Application called CreateFile() to connect to the pipe the server opened,
and return was return connected = true. However in the ServerApp, ConnectNamedPipe() is still waiting for the client to connnect.
Why the ServerApp stills think there isn't a client connecting to the pipe even though the CreateFile() in the ClientApp is successfully connected to named pipe?
Thank you
|
|
|
|
|
I have an up coming project where I need to scan a map and link part of the map to a database. I am c++ and c# programmer. If there is any techology out there that is related I would like to know. I don't want to reinvent something.
|
|
|
|
|
|
Hi.
A simple question.
How could I change the fontcolor of a static control or edit box or button, etc.
For example: if I have the static control with the ID -> IDC_STATIC, what should write in InitDialog to change the fontcolor to green?.
Thank you very much.
|
|
|
|
|
Wim Summer wrote:
How could I change the fontcolor of a static control or edit box or button, etc.
Handle the WM_CTLCOLOR message of your dialog box.
Try something along the lines of:
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
<code> if(pWnd->GetDlgCtrlID() == IDC_STATIC)
{
pDC->SetTextColor(RGB(0,128,0));
}</code>
return hbr;
}
Happy Programming and God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Hi.
A simple question.
How could I change the fontcolor of a static control or edit box or button, etc.
For example: if I have the static control with the ID -> IDC_STATIC what should write in InitDialog to change the fontcolor.
Thank you very much.
|
|
|
|
|
you need to override the CWnd::OnCtlColor function in the parent window
you will need something like this
HBRUSH MyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor )
{
HBRUSH aBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID() == IDC_STATIC)
pDC->SetTextColor(RGB(255,0,0)); //red for example
return aBrush;
}
|
|
|
|
|
I am using Visual C++ 6.0 and I have problems using CBitmap.
Sometimes when I use the function
MyBitmap.LoadBitmap( IDB_BITMAP );
a debug assertion occurs:
File: wingdi.cpp
Line: 1120
The Bitmaps (256 colors, 8 Bit) were created in Photoshop. Paradoxically this assertion failure does not occur during the use of all bitmaps, only when I try to load some of them. I replaced the Bitmaps that did not work with new ones, changed the order of the bitmaps to load and deleted the debug folder, but nothing changed.
Is there any resolution for this problem?
Thank you for you help,
R.
|
|
|
|
|
Line 1120 of wingdi.h is
ASSERT(m_hObject == NULL); That means you are trying to load a second bitmap into a CBitmap object. You have to detach and delete the existing image before you can load a new one.
DeleteObject(MyBitmap.Detach());
MyBitmap.LoadBitmap(IDB_BITMAP);
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
ok, that was the point!
Thank you,
R.
|
|
|
|
|
Everybody knows the Microsoft forms 2.0 image control. I'm getting nuts with this.
I need to set the image file dynamically...but look at this.
m_imagecontrol.SetPicture(LPDISPATCH newValue);
I have a file dialog to browse the image, the question is:
how can I set the CFileDialog.GetFilename() in m_imagecontrol.SetPicture(LPDISPATCH newValue);
CFileDialog.GetFilename() is a CString, if there's a function to do this, please tell me before I kill myself.
thanks in advance pals
|
|
|
|
|
Try to look for IPicture usage. I think the LPDISPATCH param is a IPicture interface.
(rough guess)
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I'm attempting to add a gradient background to my applications main menu bar
to match what I've done to the toolbars. I've got as far as creating a
pattern brush from a bitmap and setting it as the menus background using
SetMenuInfo() but it is not being rendered correctly. The colour should go
from dark at the top to light at the bottom but what I've ended up with is
the darker half at the bottom going from dark to light and the lighter half
at the top going from dark to light. Its as if the origin for the brush has
negative coordinates. Can anybody suggest how to correct the origin of the
brush?
Systems AXIS Ltd - Software for Business ...
|
|
|
|