|
Hi Peter I have to give up for awhile as I am going nuts over grabbing this rkey.
Thanks
again for your help!
Best Wishes,
ez_way
|
|
|
|
|
Hi Peter
Is not ExpandEnvironmentString a VB function?
Best Wishes,
ez_way
|
|
|
|
|
Try this:
HKEY hKey;
TCHAR szDefaultMailClientPath[MAX_PATH] = {0};
DWORD dwSize = MAX_PATH;
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("mailto\\shell\\open\\command"), 0, KEY_READ, &hKey) == ERROR_SUCCESS &&
RegQueryValueEx(hKey, _T(""), 0, NULL, (BYTE*)&szDefaultMailClientPath, &dwSize) == ERROR_SUCCESS)
{
CString sPathWithCL(szDefaultMailClientPath);
CString sPath = sPathWithCL.Mid(sPathWithCL.Find('"') + 1,sPathWithCL.ReverseFind('"') - sPathWithCL.Find('"') - 1);
CString sEnvString = sPath.Mid(sPath.Find('%'),sPath.ReverseFind('%') - sPath.Find('%') + 1);
if (sEnvString.GetLength())
{
TCHAR szEnvStringResolution[MAX_PATH] = {0};
ExpandEnvironmentStrings(sEnvString,szEnvStringResolution,MAX_PATH);
sPath.Replace(sEnvString,szEnvStringResolution);
}
MessageBox(sPath);
}
Peter Molnar
|
|
|
|
|
Hi Peter that work now explainit please!
if (sEnvString.GetLength()) { // check that there is a value
TCHAR szEnvStringResolution[MAX_PATH] = {0}; //set to NULL
ExpandEnvironmentStrings(sEnvString,szEnvStringResolution,MAX_PATH); // really confused here
sPath.Replace(sEnvString,szEnvStringResolution); // this one I understand
What I am trying to understand is how the macro gets the env path?
Thanks again!
Best Wishes,
ez_way
|
|
|
|
|
if (sEnvString.GetLength())
{
TCHAR szEnvStringResolution[MAX_PATH] = {0};
ExpandEnvironmentStrings(sEnvString,szEnvStringResolution,MAX_PATH);
sPath.Replace(sEnvString,szEnvStringResolution);
}
MessageBox(sPath);
Peter Molnar
|
|
|
|
|
Could someone please explain:
1, what exactly do those function decorators mean, such as WINAPI, FAR, PASCAL, CALLBACK, and much more?
2, what happens if I remove the decorator from a function, for example,
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
vs
int WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
what's the difference between them?
Thanks a lot.
|
|
|
|
|
Those are used to define the behaviour of the function's call-stack and addressing.
PASCAL means that the parameters passed to that function are arranged backwards on the stack as compared to the C/C++ calling convention. WINAPI is the same as FAR PASCAL. FAR means the function uses 32-bits for addressing. I'm not sure exactly what CALLBACK means.
You shouldn't remove them!
|
|
|
|
|
Terry O`Nolley wrote:
I'm not sure exactly what CALLBACK means.
CALLBACK is the same as __stdcall which is the same as PASCAL
--
Must I be the meat in an imbecill sandwich?
|
|
|
|
|
|
There are two basic ways of passing parameters to a function: right-to-left and the caller removes them from the stack once the function is done, or left-to-right and the function itself removes them. The former is called cdecl and the latter stdcall . All those macros (aside from FAR ) resolve to either __cdecl or __stdcall and denote the function's calling convention. They tell the compiler how to handle the parameters when the function is called.
You can ignore FAR since that is a leftover from the days of segmented memory architectures. All that went away with Win32 and its flat memory model. The various macros that all resolve to the same thing (like PASCAL and CALLBACK ) used to be different things, but again that's all gone away in Win32.
[VS hint: highlight a macro and press F12 to jump to its definition.]
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
You cannot stop me with paramecium alone!
|
|
|
|
|
Your answers really helped, I appreciate.
So all functions have type of either _cdecl or _stdcall (functions are _cdecl by default?), and neither of them are important anymore in Win32. But were they important in Win16? If I messed up with the two types in a Win16 application, what would go wrong?
|
|
|
|
|
They do important in Win32. First and foremost __cdecl and __stdcall identify a calling convention of a function.
Calling convention includes 2 major things:
- argument passing order in the stack
- stack cleaning responsibility.
A code of a function and a code of a call to that function must agree and support the same calling convention. Because these codes can be located in differnt compilation units (files), the information about calling convention must be known by linker, alltogether with the function name. This information is passed to linker in the form of a decorated function name. Decoration schemes for __cdecl and __stdcall types of call are different.
That means that if we have, for example, __cdecl function defined in one file and declaration of this funcion as __stdcall in another file (say, by mistake), we will not be able to call this function from another file. The linker will complain about unresolved external symbol.
Note that C++ uses other than C decoration schemes both for __cdecl and __stdcall.
bni777
|
|
|
|
|
Anyone help me with automation in word...trying to get a .jpg logo in header of first page ONLY of a report?? I would appreciate some code as an example. I can load a .jpg, but it goes to the header of ALL pages right now, and thats not what I am looking for. Alos, how do I get a footer done, say with some text and page numer of report? I want to use MFC. Here is my code to load the .jpg to all pages:
// Get the documents collection and add a new document
Documents documents(application.GetDocuments());
_Document document;
document = documents.Add(&varEmpty,&varEmpty,&varEmpty,&varEmpty);
// Get the selection - this is the bit that we actually do the writing to
Selection selection(application.GetSelection());
//loads header for all pages****not what I want
Sections sections(document.GetSections()); // document is your instance of _Document
Section section1(sections.Item(1));
HeadersFooters headers(section1.GetHeaders());
HeaderFooter header(headers.Item(1));
Range rangeHeader(header.GetRange());
InlineShapes shapes(rangeHeader.GetInlineShapes());
shapes.AddPicture("C:\\Inspec\\LogoInspec.jpg", &varEmpty, &varEmpty, &varEmpty);
header.SetLinkToPrevious(FALSE);
*****************************************
Thanks for your help.
|
|
|
|
|
if i remember word lets u define different headers for different pages kinda like style sheets in html
my guess would be u have to set a diff (non-jpg) header for the subsequent report pages
"there is no spoon" biz stuff about me
|
|
|
|
|
So...I want to be able to layer CBitmaps,CStatics, and CRichEditCtrls in a way similar to either Microsoft Publisher or Adobe Photoshop. What's the best way to do this? (and, maybe you could also give me some hints as to how to properly print something like that).
halblonious
|
|
|
|
|
multiple memdc's with alpha blending of the bitmaps contained there-in
printing would be the same
"there is no spoon" biz stuff about me
|
|
|
|
|
OK, thanks. I don't suppose you could give me a quick run-down or a little example of how to do that? I've been programming for like a year now, but everything's still news to me.
halblonious
|
|
|
|
|
hi all
how do i confine users on a computer for delete,rename folders & formatting drive
i know hooking usage but i dont know to trap
wiche message?do u know.
|
|
|
|
|
I am not sure what you are trying to do. Do you want to stop users of your software from using delete, rename, and formatting?
Well I do not have an answer but I do have a recommendation. The best book on advanced Windows programming is "Programming Applications for Microsoft Windows" 4th Edition by Jeffrey Richter.
Enjoy and good luck!
INTP
|
|
|
|
|
The question is not what you enable users to use but what you disable.
By hooking API functions you redirect execution of this functions to yours by modifying the Import Address Table in system dll's linked to executables.
The solution to your problem is therefore hooking all functions (e.g.:CopyFile, ReadFile, WriteFile) which you want users to not use.
A good place to start:
http://www.codeproject.com/useritems/api_monitoring_unleashed.asp[^]
Peter Molnar
|
|
|
|
|
When using int's, CString's, etc in my MFC app's I have declared the ones required for the life of the object in my class header file and then used them where needed in helper functions. Now I am tring to use CList templates (read newbie) in the following way
#include <afxtempl.h>
class whatever
{
public
void AddWords();
.
CList<cstring, cstring&=""> wordList;
.
.
};
whatever::AddWords
{
CString temp;
//CList<cstring, cstring&=""> wordList;
.
.
wordList.AddTail(temp);
.
.
}
when I do this I get an assertion error stating
if (!AfxIsValidAddress(pOb, sizeof(CObject)))
{
TRACE0("ASSERT_VALID fails with illegal pointer.\n");
if (AfxAssertFailedLine(lpszFileName, nLine))
AfxDebugBreak();
BUT, when I create wordList in the AddWords helper function (ie uncomment here and comment there) my code works fine.
I have trawled through books and websites to no avail for an answer so now think this must be a really stupid question. Never the less, I need an answer and would appreciate any help.
Thanks in advance.
Dave
|
|
|
|
|
Dave again, just to let you know Im not a complete numpty and the formatting performed by the HTML,PHP whatever editor removed part of my message. should have read
CList:CString, CString&: wordList;
where the : is the appropriate greater than or less than symbol. same for my include which is of course afxtempl.h
thanks
|
|
|
|
|
I just posted and deleted my post because I feel its incredibly dumb. (What I want to do I know how to with CSdioFIle and atof, but I want to try with fread). I have a txt file that looks like this:
0
0.0500
0.0990
0.1490
0.1980
0.2430
0.2870
0.3310
0.3740
0.4150
0.4530
0.4920
0.5300
with the leading spaces (4 spaces). I copied this data from matlab and pasted into notepad. I want to load this data into an array of doubles. I did the following but evidently I dont know how to use fread inspite of re-reading the docs and googling. It just doesnt click
FILE* fpRed = fopen("red64.txt", "r");
if (!fpRed ) return;
double red64[64];
while (!feof(fpRed))
{
for (int i = 0; i < 64; i++)
{
fread(red64+i, sizeof(double), 10, fpRed);
double r = red64[i];
}
}
fclose(fpRed);
I put down 10 because its 4 white spaces + 6 spaces in the number itself.
If theres invisible stuff in the file I dont know......
Thanks for helping,
ns
|
|
|
|
|
Are you sure there are four spaces at the beginning, and not one tab?
|
|
|
|
|
It backs up one by one four spaces. If it were a tab what would I do for nItemstoRead?
Anyways for the first few elements I removed the spaces so there numbers start flush at the left, and yet when I step through I get garbage. This time I said nItems = 6 since 0.5000 etc.
Thanks for helping,
ns
|
|
|
|