|
you can use fopen, fread, fwrite, and finally fclose. google for those functions.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
That all depends on what you are using to open/create the file. Some possibilities include:
fopen()
CreateFile()
CFile
ofstream Each of these has their own way of opening/creating a binary file.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
With fopen, fread and fwrite.
Here's a rough n nasty example:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
long i;
long fLen;
long tmpValue;
fp = fopen("test.dat", "r+b");
if (fp == NULL)
{
printf("File doesn't exist\n");
printf("creating...\n");
fp = fopen("test.dat", "w+b");
}
if (fp)
printf("File opened successfully.\n");
else
return -1;
for (i=0; i<100; i++)
fwrite(&i, sizeof(i), 1, fp);
fseek(fp, 0, SEEK_END);
fLen = ftell(fp);
fseek(fp, 0, SEEK_SET);
for (i=0; i<fLen/sizeof(long); i++)
{
fread(&tmpValue, sizeof(long), 1, fp);
printf("%4d", tmpValue);
}
fclose(fp);
return 0;
}
|
|
|
|
|
Thanks, this looks quite helpful, i will get to work on this
|
|
|
|
|
Hi All
I have a question about mouse right click.I want to do if mouse right click on MyComputer Drive(C:\,D:\,...) then Message Show of Drive Name.
User click on C:\ drive then message show C and if user click on D:\ drive then message show D.
Is it possibel?If yes then how can i do?
Plz help me
|
|
|
|
|
Do you need this implimentation in Explorer window?
-@SuDhIrKuMaR@-
|
|
|
|
|
can you give me API or example for this..
Plz help me
|
|
|
|
|
Seems you are trying to integrate "something" into explorer's context menu. Whatever it may be, you've to modify explorer's context menu.
1) One method is to write shell extension to implement IContextMenu . Refer this excellent article by Michael Dunn[^].
2) if you want to do it in very simple method without writing shell extension, then modify registry to add a specific menu item to shell which will execute your specified executable on clicking. Check the "Explorer Context Menu" section in this link[^].
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi everybody, iam trying to prevent the user from resizing, maximizing and minimizing a FormView window by using : OnSize and OnSizing functions, but it did not work? can somebody help? Thansk in advance
|
|
|
|
|
U r using Mdi Application ?
Than Override OnSize in CChildFrm and you will get the functionality.
|
|
|
|
|
susanne1 wrote: Hi everybody, iam trying to prevent the user from resizing, maximizing and minimizing a FormView window by using : OnSize and OnSizing functions, but it did not work? can somebody help? Thansk in advance
You can handle WM_GETMINMAXINFO or in MFC add a message map entry called
ON_WM_GETMINMAXINFO and function prototype looks like this ...
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
For disabling window resizing you've to handle WM_GETMINMAXINFO message. Check this [^]for code snippet.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi Jijo, thanks for your reply, i used WM_GETMINMAXINFO message but it did not work(visual studio does
not come to it)
Any idea why?
Thanks
|
|
|
|
|
susanne1 wrote: Any idea why?
Without seeing your code, it's going to be hard to say for sure. Did you use ClassWizard to create the handler function for it, or did you try to implement the function manually?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Whether its MDI/SDI? And you're trying to restrict that of a child view?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
susanne1 wrote: Subject:Visual C++6
susanne1 wrote: iam trying to prevent the user from resizing, maximizing and minimizing a FormView window
So your question is not about Visual C++ 6, is it ?
|
|
|
|
|
sure it is about VC++6 / MFC
|
|
|
|
|
are you on crack ?
when you ask a question, the topic has to be specific, and not talk about the TOOL you're compiling your code with !
|
|
|
|
|
Hi,
I am using ClistCtrl Control with two column one displays the URL and the other displays the time.
I want that the url should appear as a hyperlink rather than a normal text and on clicking it the specified url should open in a browser
The code is as follows:
void CGetFootDlg::GetFootPrintURL(int n,CString strResponseFootPrints,CString g_strDelimFLD)
{
if(n>-1)
{
if(strResponseFootPrints.IsEmpty())
return;
CStringArray* ptrstrArray = CParser::Parse(strResponseFootPrints,g_strDelimFLD);
int j=ptrstrArray->GetSize()-1;
TCHAR szName[] = _T("Sandra C. Anschwitz");
::IsWindow(m_lstGetFootPrints.m_hWnd);
for(int i=0; i<ptrstrarray->GetSize(); i++)
{
LV_ITEM lvItem;
ZeroMemory(&lvItem, sizeof(LVITEM));
lvItem.mask = LVIF_TEXT;
lvItem.iSubItem = 0;
lvItem.iItem = i;
lvItem.pszText = szName;
lvItem.iImage = 0;
int nItem=m_lstGetFootPrints.InsertItem(i,szName);
int start=0,end=0,len;
CString str,strFPurl,strFDuration;
str=ptrstrArray->GetAt(i);
strFPurl=strFDuration=str;
len=str.GetLength();
end=strFPurl.Find(' ',0);
strFPurl=strFPurl.Mid(0,end);
start=strFDuration.Find(':',end+1);
strFDuration=strFDuration.Mid(start+1,len-1);
m_lstGetFootPrints.SetItemText(nItem,0,strFPurl);
m_lstGetFootPrints.SetItemText(nItem,1,strFDuration);
}
}
}
Can anyone help me.
Thanks
Dhiraj Kumar Saini
|
|
|
|
|
Dhiraj kumar Saini wrote: Can anyone help me.
Google[^] does sometimes help!
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi all
I'm wanting to retrieve the current keyboard and mouse state without having to wait for an event message.
I basically have a main thread and a window thread. The window thread handles the windows message pump so that if my app locks up, it can still process close messages etc. The main thread is where I am wanting to do the device state reads.
Everything I've looked at so far (RAWINPUT, SetWindowsHookEx) rely on an event message being posted before I am able to read the state from the device. This is no good to me.
I've also looked at GetKeyboardState(..) but that only retrieves the keyboard state in the thread that is handling the windows messages, so calling it from the main thread does not work (but calling it from the window thread does).
I'm starting to think the only way is to get access to the device driver and directly read from the device.
Anyone know any decent articles on this?
Thanks,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote: I've also looked at GetKeyboardState(..) but that only retrieves the keyboard state in the thread that is handling the windows messages, so calling it from the main thread does not work (but calling it from the window thread does).
Not sure because I have not used this function much, but anyway MSDN says this...
The status does not change as keyboard messages are posted to the thread's message queue, nor does it change as keyboard messages are posted to or retrieved from message queues of other threads. (Exception: Threads that are connected through AttachThreadInput share the same keyboard state.)
Does that help?
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Hi thanks for the reply, but it doesn't really help me. I've read the MSDN articles pretty thoroughly and that function basically only works on threads which have created a window using CreateWindow or CreateWindowEx and have a message pump. Since I've created the window on a separate thread, GetKeyboardState() only actually works if it's called within that threads loop, but it won't work on another thread unless AttachThreadInput() is used to share the message processing. However, AttachThreadInput() cannot be attached from or to the system thread (which is the one i'm using for my app) and in any case it would need to be a thread that has created a window and uses a windows message pump as well, which it does not.
Looks like what I'm after is quite low-level, raw device state reading functionality but all I'm seeing is Windows event driven solutions. There's got to be a way to bypass all this windows guff and read directly from whatever hardware is present..surely..?
Cheers for trying tho
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
hi
iam doing a project where it has 2 different apps
1. bluetooth app
2. device driver app.
both in c++.
now can i implement a shared memeory concept in (c++) windows where both the process should access a single place for the data.
if possible how to do it.
|
|
|
|
|
manju23reddy wrote: shared memeory concepts
Actually, the jargon is IPC[^].
There are several ways mechanisms supported by windows to achieve IPC, one of which would be to use WM_COPYDATA[^]. Look up MSDN[^] for more details. You may also search for articles on individual topics at CP and Google. There are plenty of examples around.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|