|
I'm also amazed at how many C# programmers apparently have no clue as to the meaning of the message "Object reference not set to an object instance.".
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: C# programmers dabblers apparently have no clue as to ...
FTFY
|
|
|
|
|
hi,
is there any method to find out file is password protected or not.
thanks.
|
|
|
|
|
What file? Please be more specific.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
word or excel type files.
|
|
|
|
|
HI,
i just want to know, if i inter-change my office document file to each other, like .doc, to .xls or .ppt
than after interchanging the file type the file not open properly when i m trying to open now is there any way to identify waht is the original file type/
thanks.
|
|
|
|
|
Short answer: No.
The file type of a file is whatever it is at the moment you access it. Unless it contains some control information which identifies what it was created from then there is nothing that will help you.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Le@rner wrote: i just want to know, if i inter-change my office document file to each other, like .doc, to .xls or .ppt
What do you mean by "inter-change a file"?! A document file cannot be somehow magically converted to a spread sheet, and vice versa. If you just renamed the file to change its extension (from .doc to .ppt), that doesn't mean power point can open it now.
And how is your question even related to C++ or MFC?!
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
i am reading file properties,
i want to indetify these type of file in my application.
|
|
|
|
|
Le@rner wrote: i am reading file properties,
from where?
|
|
|
|
|
using CComPtr<ishellfolder2> pShellFolder2;
|
|
|
|
|
I was thinking the same thing... those file types he named aren't even anything alike. 
|
|
|
|
|
As Richard MacCutchan mentioned, the file content can give you a hint. Although programs are free to write whatever they want in files, many popular file types contain signatures that make them recognisable.
This[^] page contains a list with many file extensions and their signatures, including Microsoft Office files.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
i chked.
my all word,excel or ppt file had D0 CF 11 E0 A1 B1 1A E1
and no hint find on 512 byte offset,
now how can i idetify the file.
|
|
|
|
|
As I said before, there is no guaranteed method to identify file types. Much of Microsoft's software uses specific patterns as identifiers within their files but the information tends to change and is generally not published.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Assuming by 'interchange' you mean rename, then no.
If you mean you load it into MS Office as one type and then use 'save as' to store it in another format (e. g. load a .xls into a word document and then store the rsulting document as .doc), then you can no longer expect to be able to open it with the original program. You may be able to convert it back, but usually you'll lose a lot of extra information that way.
In any case, on Windows file name suffixes are directly tied to applications. That is why, when you try to rename a file suffix in Explorer, you will get a warning that you may no longer be able to properly open and work with that file.
Unfortunately MS never thought to force aplications to store file types right into the file itself rather than encoding it into fickle properties such as a name suffix. It makes too much sense I suppose...
|
|
|
|
|
I have my getline working, and I have just been schooled in file formats, such as UTF8, UTF16LE and UTF16BE. I also learned about the BOM, to figure out what kind of file I have, in case the customer modifies the original.
So I can use my wifstream to open a UTF8 SQL Text file, and read it correctly, with no 16 bit gaps. I originally used ifstream and wifstream to read a Unicode UC2 file, and got the every other character sequence, So I exported the file as UTF8, and tried again.
The getline puzzles me, and it has something to do with \n.
sqlDBFile->getline(szCommandLine, 1024);
First line reads ok
i>>?--SQL Comment --
second line is missing the first char.
REATE instead of CREATE
Here's my theory
0x000d 0x000A is end/begin mark, and getline is terminating beyond the \n.
I really need that first character, so I can detect the word GO, instead of getting O.
|
|
|
|
|
 Well I got it finally, documentation is poor, but it was there.
getline - gets the line, and keeps the /n
gets - get the line, and discards the /n
I used a do loop with a while (sqlDBFile->get()) at the end, so it was chopping off the first char of the next line.
So this is what I ended up with, but I'm not sure if I need the conv at the top
typedef std::codecvt<wchar_t, wchar_t, mbstate_t> nullcodecvt;
const nullcodecvt &conv =
std::use_facet<nullcodecvt>(std::wcin.getloc());
const std::locale from(std::wcin.getloc(), &conv);
std::wifstream *sqlDBFile = new std::wifstream;
sqlDBFile->open( szFilePath, std::ios_base::in );
if (sqlDBFile->is_open() ) {
if (_wcsicmp(szEncoding, L"UTF8") == 0 ) {
sqlDBFile->seekg(3, std::ios::beg);
}
WCHAR *pzSQLCommand = new WCHAR[8192];
wcsncpy_s(pzSQLCommand, 8192, L"-- SQL Command Buffer --\n", wcslen(L"-- SQL Command Buffer --\n") );
while (sqlDBFile->good() ) {
while (!sqlDBFile->eof() ) {
WCHAR szCommandLine[1024];
for (int i = 0; i<1024; ++i) {
szCommandLine[i] = 0xcccc;
}
sqlDBFile->getline(szCommandLine, 1024);
if (szCommandLine[0] == 0x002d)
continue;
if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0x0000))
continue;
if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0xcccc))
continue;
if (_wcsicmp(szCommandLine, L"GO") == 0 ) {
hr = pICommandText->SetCommandText( DBGUID_DBSQL, pzSQLCommand );
hr = pICommandText->QueryInterface( IID_ICommandProperties, ( void ** ) &pICommandProperties );
hr = pICommandText->Execute( NULL, IID_IRowset, NULL, &cRowsAffected, ( IUnknown ** ) &pIRowset );
for (int i = 0; i<8192; ++i) {
pzSQLCommand[i] = 0xcccc;
}
}
else {
szCommandLine[wcslen(szCommandLine)] = L'\0';
wcsncat_s(pzSQLCommand, 8196, szCommandLine, wcslen(szCommandLine) );
continue;
}
}
}
delete pzSQLCommand;
sqlDBFile->close();
sqlDBFile = NULL;
}
|
|
|
|
|
RTL_QUERY_REGISTRY_TABLE query_table[2];
RtlZeroMemory(&query_table[0],sizeof(query_table));
RtlZeroMemory gives error
please guide..
Answer:
Firstly sorry for late reply,
It was really a very strange error, or one can call it a bug.
I just uninstalled the visual studio express ide and re-installed it. After that RtlZeroMemory error had gone. I guess some exception or bug had occured in the ide or compiler or god knows. But it worked.
Thank you all, for sharing your precious time with me.
Regards,
Vishal
|
|
|
|
|
RtlZeroMemory(query_table, sizeof(query_table));
As described in the document use the ZeroMemory macro instead of the function.
|
|
|
|
|
i had done the same thing but still the same error pops.
Regards,
Vishal
|
|
|
|
|
|
|
Doesnt say it should be used in place of the Rtl though.
==============================
Nothing to say.
|
|
|
|
|
That's a struct , try this...
RtlZeroMemory((void *)query_table,sizeof(RTL_QUERY_REGISTRY_TABLE)*2);
|
|
|
|