|
Hi all,
I am working on VS10 Porting project.
Here they are using _fstat(infile.rd(), &instat).
This function is used to obtain information of the opened file associated with the
File descriptor.The first parameter in this function is File descriptor.
But,File descriptor is not available in VS10.
So,How can we use this function without File descriptor?
Please help me to solve this issue.
Thanks.
|
|
|
|
|
|
Sorry, I found your earlier question in which you said it was an ifstream that you were using.
From what I can see there is no way of getting anything useful toward a file handle out of the ifstream, short of making a hack for it.
I would recommend using functions like CreateFile and GetFileSize using handles or just opening the file a second time with _open(name, _O_RDONLY, _SH_DENYNO) depending on what information you are wanting.
If you really really want to stick with ifstream, then this is a hack that will get the file descriptor out for the version I have. It may be different than your version due to hotfixes.
ifstream::_Myfb *pFileBuffer = infile.rdbuf();
char *pFileBufferMemory = (char *)(void *)pFileBuffer;
FILE **pFilePtrPtr = (FILE **)(pFileBufferMemory + sizeof(ifstream::_Myfb) - sizeof(FILE *));
FILE *pFilePtr = *pFilePtrPtr;
int nFileDescriptor = _fileno(pFilePtr);
int nFileDescriptor2 = _fileno(*(FILE **)(((char *)(void *)infile.rdbuf()) + sizeof(ifstream::_Myfb) - sizeof(FILE *)));
|
|
|
|
|
Hi all,
I am trying to get Logical drives of a hard disk(\\.\PhysicalDrive0).
I have tried using DeviceIoControl function for it but i am getting GetLastError() = 122 i.e. ERROR_INSUFFICIENT_BUFFER error.
My code is as follows:-
HANDLE hDevice;
hDevice = CreateFile("\\.\PhysicalDrive0"
0,
FILE_SHARE_READ |
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
PARTITION_INFORMATION_EX obj;
DWORD cb;
BOOL iu = DeviceIoControl(hDevice,
IOCTL_DISK_GET_PARTITION_INFO_EX,
NULL,
0,
&obj,
sizeof(obj),
&cb,
NULL
);
if(iu == 0)
{
DWORD err = GetLastError();
CString str;
str.Format("%d",err);
AfxMessageBox(str);
}
CloseHandle(hDevice);
I am not getting where exactly is the problem...
How can i do this..
Thanks in advance
|
|
|
|
|
Not sure if it is just the way u copied it to code project, but you need to escape each of the back slashes in the drive name like "\\\\.\\PhysicalDrive0"
also add a comma in after that string. Once I applied those changes your code worked for me.
|
|
|
|
|
I created a CWnd control with widow styles WS_CHILD|WS_VISIBLE (parent is a CWnd also), then set a new CFont to the control by SetFont(...) function.
But, when called
CFont*pFt=GetFont();
inside the CWnd control, return value of pFt is null.
Should I add more window styles?
How do you set a font to CWnd to ensure that GetFont() is valid?
BTW: I tested to create a CStatic, GetFont() is still null;
modified on Monday, January 10, 2011 11:39 PM
|
|
|
|
|
See comments here[^] about the return value from the WM_GETFONT message.
I must get a clever new signature for 2011.
|
|
|
|
|
Additionally, it will return 0 too when called on a control/window that doesn't exist (yet/anymore/at all).
modified 13-Sep-18 21:01pm.
|
|
|
|
|
At which point do you call GetFont? Does the window already/still exist at that point?
Calling it from within OnCreate() should be safe to ensure the font has been set.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Just call GetFont immediately after SetFont, so that we can test whether the problem is with invalid window handle. For a valid window handle it must work.
If u can Dream... U can do it
|
|
|
|
|
Hi there:
I am trying to get a clob data via store procedure in oracle db by using ADO . But I don't know how many bytes should I allocated for the buffer to hold the clob out value. Is there a convenient way to get the clob out value properly ?
I googled and found some guys say that ADO.Stream can be used on this problem but I failed to find how to use ADO.stream in
Thanks a lot.
----------
Don't look at me in that way!
|
|
|
|
|
I have a CFormView with 2 CStatic bitmaps used for backgrounds. One has an ActiveX graph control above it and the other has another bitmap. Z order is set so background bitmaps are on the bottom. Clip children and clip siblings are set. When first displayed everything looks good. After minimize/restore or covered by another window the background bitmaps display above the other controls.
To test I added a button and have the handler in CFormView that does m_graph.Invalidate() and m_foregroundbitmap.Invalidate(). When pushed the graph and forground bitmap display correctly. I also tried having the button handler just do Invalidate() (for the form view) which also displays correctly. Putting Invalidate() in any other handler (i.e. OnSize, OnActivate) doesn't work. It seems that the graph and foreground bitmap update but then the background bitmaps update and draw over the others. Setting Invalidate() in OnParentNotify() from the graph control does work but unless the mouse is over the control there's no notify messages so no update. I've also tried SetWindowPos(&CWnd::wndTopMost... which didn't seem to change anything.
Are there any ideas on what I might be missing or maybe another way to have controls over an image? (I need the background image because it gives a quick view to what changed in the control.) Thanks,
John
|
|
|
|
|
Z-Order for the child controls will not work for displaying a child window on the top of another.
What you can do is instead of using a CStatic control for displaying the bitmap, you can render the bitmap directly on to the parent window.
|
|
|
|
|
My flight simulation club is working on the development on an opensource flight simulator (Fly! Legacy) under GPL license.
http://sourceforge.net/projects/flylegacy/[^]
Currently, only a Windows version of this software is available and so, one or several people would be necessary (because the current developers are very busy at the time) to help us to convert this Windows application to a Linux application.
The application is developed in C++ and is compiled with Visual Studio 2008.
About the librairies included in the project, I don't know all because I'm not developer of the project but I can tell you that uses:
_ OpenGL
_ OpenAL
_ FreeImage
_ OPAL-ODE
_ Glew
_ PThread
_ STLport (not sure)
Could you help us ?
Thank you for your cooperation.
|
|
|
|
|
I see the goal of the project, but what exactly is the problem?
Also, is it necesary to convert the project to Linux? Running it in an emulator is not a viable option?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
The problem is that we have a lack of developers on the project and as the result, those who developed the project at the moment don't have the opportunity to convert the Windows application into a Linux one, because they are working on more important priorities (like the creation of a 1st aircraft).
I heard that this task would be pretty fast to do (a couple of days), but for the moment, we don't know anybody who have the skills to work on this.
Unfortunately, an emulation solution (Wine, even a virtual machine) was rejected by the developers, mainly for performances reasons.
|
|
|
|
|
I meant, what is the programming problem?
Or should the question be seen as a request to do the full conversion project for you?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
There is no programming problem.
Indeed, if we could find someone who would accept to do the conversion for us, that would be perfect.
|
|
|
|
|
Stephane-M wrote: if we could find someone who would accept to do the conversion for us, that would be perfect.
In that case you should post in the appropriate forum; your question has nothing to do with C/C++.
I must get a clever new signature for 2011.
|
|
|
|
|
|
|
No, we never tried Wine but the team has already rejected this solution because it wants a native Linux software, not an emulation or a virtual machine, mainly for performances reasons.
|
|
|
|
|
|
Hey guys,
I was just wondering, given Master File Table entries on an NTFS system, how would one retrieve the directory of the file? I understand there's an Index attribute somewhere, but i'm not sure how to read the index and convert it to a path or position.
Example of a file:
- Directory path: C:\Archives\
- Filename name: 09011105010CITV.txt
- Full directory path: C:\Archives\09011105010CITV.txt
I made these two files and ran a scan on my Master File Table. Using a custom built Hex Viewer, these are the two hexadecimal outputs of the files: MFT output[^]
Those are the blocks of data in the Master File Table. Now i'm going to try and see if I can try and figure out how to link the two together, but otherwise can anyone else lend a hand? Thank you.
Much appreciated!
|
|
|
|
|
This is a fairly large subject; I suggest you start by researching here[^].
I must get a clever new signature for 2011.
|
|
|
|