|
Well... What I have is a listbox. Each line in the file is a line in the listbox.
For my purposes, this is what I'm doing...
CStdioFile MyFile;
CListBox MyListbox;
MyFile.ReadSrting(String);
MyListBox::AddString(String);
Thats in a loop until EOF is reached. If I could do this directly from the resource, that would be great.
Thanks for the reply.
|
|
|
|
|
Daniel1324 wrote:
Each line in the file is a line in the listbox.
...
Thats in a loop until EOF is reached. If I could do this directly from the resource, that would be great.
Do you already know the value of the data? If not, resources probably aren't the answer.
|
|
|
|
|
I already know the valus... its all in a text file. Basically, what I want to do is read one line, and add that line to the listbox. Rightnow, i'm doing it by reading the text file. But, I want to add the text file into the resources so I wont have to distribute the text files with the app.
|
|
|
|
|
You can extract a resource to a file in this way:
bool ExtractResourceFile(const CString& resourceID, const CString& filename)
{
bool bOK = true;
HANDLE hRes = ::LoadResource(AfxGetResourceHandle(), ::FindResource(AfxGetResourceHandle(),
resourceID, "YOUR_RESOURCE_TYPE"));
if (hRes != INVALID_HANDLE_VALUE)
{
DWORD sizeOfResource = ::SizeofResource(AfxGetResourceHandle(),
::FindResource(AfxGetResourceHandle(), resourceID, "YOUR_RESOURCE_TYPE"));
char *lpRes = (char*)::LockResource(hRes);
CFile file;
if (file.Open(filename, CFile::modeCreate | CFile::modeWrite))
{
file.WriteHuge(lpRes, sizeOfResource);
file.Close();
}
else
{
bOK = false;
}
::UnlockResource(hRes);
::FreeResource(hRes);
}
return bOK;
}
Its up to you to delete the file once you have finished with it ::DeleteFile(filename)
Roger Allen
Sonork 100.10016
Death come early, death come late,
It takes us all, there is no reason.
For every purpose under heaven,
To each a turn, to each a season.
A time to weep and a time to sigh,
A time to laugh and a time to cry,
A time to be born and a time to die.
Dust to dust and ashes to ashes,
And so I end my song.
|
|
|
|
|
Thanks Mr. Allen. Will this also work for binary files?
Edit...
Cant get it to work... always produces a zero byte file.
|
|
|
|
|
Hi,
I have MDI project. In one of the dialog boxes, I have a Combo Box,
and according to a file (this file is read before the dialog is opened),
I have to add items to the combo box, and the number of items is different according to the read file.
how can I add dynamically to the Combo Box?
Ehsan Behboudi
|
|
|
|
|
|
|
Combo boxes only work with strings. They are "dumb" as far as data types, formating, etc. are concerned. If you want data from the file to go to a combo box, then you are responsible for reading in the data from the file, parsing the data, and adding the data to the Combo Box.
|
|
|
|
|
I'm making a program to losslessly cut commercials from WMV files, and I'm trying to figure out the best way to display the current position in the video. I'm using a TrackBar control, and it works fine, but I'd like it to highlight the part of the slider to the left of the current position, like WMP9 or other video players do. How can I do that using straight Win32?
|
|
|
|
|
|
It would, but it uses MFC; I want to avoid a huge exe size, so I can't use MFC
|
|
|
|
|
IGx89 wrote:
I want to avoid a huge exe size
Your app is huge even if you link dynamically with the MFC DLLs?
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Well, it's about ~40kb now; with MFC (static) it'd probably be close to 200kb, and MFC (dynamic) would be a LOT bigger because I'd have to include the whole mfc70.dll file (or whatever it's called now). I don't think it's worth it when I'm using MFC just for one simple trackbar
|
|
|
|
|
Ah. I didn't realize you meant the app's footprint vs. its size. But if you're using VC7 (as it appears), don't you have to include the new MSVCRTL (and possibly other) DLLs anyway? Just curious.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I have it staticly linked to those DLL's; including wmvlib and other DShow lib's, and using UPX compression, the final exe is exactly 60kb, and isn't dependent on any DLL's (besides standard DirectShow ones that come with DirectX).
|
|
|
|
|
hi again,
msdn tells, that select will return a recv event, when the connection is closed, terminated or reseted, not only when there is data to read.
is there an easy way to distinguish between a close and a read event?
thx for help
Don't try it, just do it!
|
|
|
|
|
Yes, do a read on the socket and it will return 0 - the socket is closed.
|
|
|
|
|
hi,
i have a dll, exporting a c++ class(u know all these crazy export names), and i want to code a software, to link them runtime! So GetProcAddress will get problems!
any solution?
thx
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
and i want to code a software, to link them runtime! So GetProcAddress will get problems!
What do you mean? Are you having problems accesing the functions with GetProcAddress() now, or do you intend to write functions which cannot be accessible using GetProcAddress()?
--
They're out get me, I can't escape cos' they won't let me
They won't forget me, they'll get me in their grip and sweat me
They'll wait me out, and then move in under my skin
They'll make me doubt, they're out to make me let them in
|
|
|
|
|
Hi,
How can I get the current username from a NT service?
GetUserName() and WNetGetUser() returns allways "SYSTEM"
tx
|
|
|
|
|
it's not that easy as u think!
it is possible, that multiple users are logged on at one machine!
Don't try it, just do it!
|
|
|
|
|
That's because you have configured your service to run under the LocalSystem account and that is in fact the correct username.
Presumably what you want is to find out the username of the whomever is logged onto the interactive console at the time? (Keeping in mind that the answer might be 'no one'.)
A sketch of the solution is as follows:
1) Call OpenWindowStation("WinSta0", FALSE, WINSTA_READATTRIBUTES) to a handle to the interactive WindowStation.
2) Call GetUserObjectInformation(hWinSta, UOI_USER_SID, ...) to get the SID of the user currently logged onto that WindowStation.
3) Call LookupAccountSid(...) to get the username from the SID returned above.
Points to consider:
If you are running on a version of the OS with Terminal Services installed you should start with the WTSEnumerateSessions() first to determine which WindowStation name you care about. This includes WinXP and W2K3 as they use the terminal services infrastructure all the time.
You may not really want the name, for anything security related you should probably be comparing against or logging that SID obtained in step three directly. Usernames can be duplicated between local and domain accounts and can change over the lifetime of an account, SIDs do not.
-Blake
|
|
|
|
|
Using VisualC++ 6.0 SP5 I create a new MFCAppwizard(exe) project named "my". I choose SDI with doc/view architecture support then click finish to leave all other options at their defaults. Since the project is named "my" the classes created are "CMyApp", "CMyDoc", "CMyView", "CMainFrame" and "CAboutDlg". If I build it now it will run fine so far. Then if I include the header for the CMyView class in the cpp for the CMainFrame class like so:
<br />
<br />
#include "stdafx.h"<br />
#include "my.h"<br />
<br />
#include "MainFrm.h"<br />
<br />
#include "myview.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
...<br />
...<br />
...<br />
it does not compile. The 3 errors it gives are really weird:
myprojects\my\myview.h(21) : error C2143: syntax error : missing ';' before '*'
myprojects\my\myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myprojects\my\myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
weird, eh? I noticed that if you move the #include "myview.h" line to the top of the file (i.e. before the other three #include statements) it will compile but if you make reference to anything that was declared in myview.h it will give an error saying "undeclared identifier".
For example if I wanted to create a pointer to a CMyView class within the constructor of the CMainFrame class like so:
<br />
CMainFrame::CMainFrame()<br />
{<br />
CMyView* p;<br />
}<br />
it gives the following error messages:
MyProjects\my\MainFrm.cpp(45) : error C2065: 'CMyView' : undeclared identifier
MyProjects\my\MainFrm.cpp(45) : error C2065: 'p' : undeclared identifier
MyProjects\my\MainFrm.cpp(45) : warning C4552: '*' : operator has no effect; expected operator with side-effect
(remember that is with the #include "myview.h" moved to the very top of the mainfrm.cpp file
anybody know why it doesn't like what I'm trying to do? I'm a bit new at this and I searched the forum for someone asking the same question but didn't find anything relevant.
thanks!
-Oinka
|
|
|
|
|
Oinka wrote:
myprojects\my\myview.h(21) : error C2143: syntax error : missing ';' before '*'
myprojects\my\myview.h(21) : error C2501: 'CMyDoc' : missing storage-class or type specifiers
myprojects\my\myview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
There are two solutions to this problem.
1. Add #include "MyDoc.h" before the "MyView.h" include
2. Forward declare CMyDoc in the MyView.h header file.
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|