|
A buffer with a length of 200 chars is more than large enough for a format specification of Error: %lx .
The crash is also happening outside of the try /catch block - it is happening when you return from the function. IME, a crash on return from a function is due to a fulblungered return address. Generally, this is due to stepping on your stack somehow. you can poke around by increasing the stack used both in the function and around any buffers populated by the function.
For example, add TCHAR __caCrashBuf1[ 1024 ] at the top of the function, and something like TCHAR __caCrashBufzyx[ 1024 ] around any buffers used by the function. If you do that and the crash stops or changes, you can narrow down the location that is stepping on the stack.
I would also be investigating that TGTTRACE(...) function. FWIW, it also looks like you can get rid of the logmsg buffer by building the error string in the TGTTRACE(...) function (no need to build strings twice):
TGTTRACE( llItemMedium, lLogError, L"Query Data Failed - Error: %lx", e.Error() ); Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Two questions:
1) What is the definition of the TGTTRACE macro? Is it defined in the release build?
2) Is this a Unicode build? Seems odd to mix the _T(..) and L... constructs.
|
|
|
|
|
TGTTrace is use to log the error into the file. It's unicode release
-- modified at 11:47 Wednesday 9th November, 2005
|
|
|
|
|
Hello,
Arn't trace macro's removed in release builds?
Anyway, maybe your stack gets corrupted by a non NULL terminated string. Use _sntprintf() instead. You can specify the max number of characters. This way you won't corrupt the stack.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hello,
ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
some_proberty = some_value
test2 = test3
url = www.codeproject.com
So there is always the name an then = and then the value. In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char. So how can I read my config file ?
With best regards,
Benedikt
|
|
|
|
|
|
Thank you !!!!
|
|
|
|
|
|
RedDragon2k wrote: In Visual C++ I would use CStrings which have the Trim, Left, Right Functions, etc. But it seems there are no such functions for the char.
Sure there is. If they did not exist for char , then the CString class would not have such methods (since it is based on a char type). Why not just copy the code from the three CString methods into your project? It'll work fine.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
RedDragon2k wrote: ok my problem is that i don't know how to parse a config file. The file is read line by line into a char[255]. The config file looks like this:
Two Option :-
#1. Use GetPrivateProfileString() api to extract data from file
#2. use CStdioFile::ReadString() method (which read the File Line by line) and then you have to parse the data manaully
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
is there a way to change values of domain users HKEY_CURRENT_USERS key on a particualr machine while that user is not logged on.
a programmer traped in a thugs body
|
|
|
|
|
How will the HKCU hive exist if there is no current user? Perhaps you'll want to update the HKU hive instead.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
If you have a local user its current user comes from one the HKU key. However we don't have roaming profiles in our environment but a domain user can log onto a machine make changes to his HKCU values and it is retained however if I'm logged on as an admin I can't find a key under HKU tat corresponds to that user.
a programmer traped in a thugs body
|
|
|
|
|
My guess is that the registry hive for the user on the domain is located on a server somewhere, in which case you need a remote registry connection and look for user profile on the domain controller or other system containing the information.
If a 'domain' user logs onto a local system and he has not been added to that local system explicitly, his prfile is probably temporary while he is logged in and thus not found within the registry of the current (local) system.
|
|
|
|
|
Take a look at the LoadUserProfile function.
The hProfile member of PROFILEINFO parameter is a registry key handle opened to the root of the user's hive
|
|
|
|
|
Can some one tell me how to add an entry to a string table. Is it as simple as inserting a String.I was looking at inserting IDS_ABC.
Thanks,
M
-- modified at 13:04 Tuesday 8th November, 2005
|
|
|
|
|
Well, you can edit the .rc and .h files manually, or you can do it via the IDE. Click the ResourceView tab on Workspace window. Right-click String Table and select Insert String Table from the context menu. Now in the right pane, either press the Insert key or right-click and select New String. Does that help?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks, That was what I was doing. Just wanted to be sure if it was done differently. Could you please explain the use of String table.
Thanks
M
|
|
|
|
|
TUMB wrote: Could you please explain the use of String table.
String resources are simply null-terminated Unicode strings that can be loaded when needed from the file. Using string literals instead would make your code harder to translate into other languages, plus it makes the memory footprint larger. String resources are not loaded into memory unless they are asked for.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I can use the 8 data lines of this port OK, but when it comes to using the other 4 output lines on the control section of the port I have no luck.
I keep getting 0x0C back when I read these lines (no matter what I set it to):-
Note Using PortTalk for Windows 2000:
Code:<br />
int ReadPortLPT1C(void)<br />
{<br />
int value = inportb(0x37a);<br />
return value;<br />
<br />
}<br />
<br />
void WritePortLPT1C(int newData)<br />
{<br />
outp(0x37a, newData);<br />
}
As I said it works fine for the data lines (8) at address 0x0378.
|
|
|
|
|
The control port on your PC may be a write only port and reading back the data from it would not be valid. You should check the lines with a scope and verify if they are toggling. If you ultimately require more read lines for your project you can add a latch circuit and use one of the control lines to swap your other signals to read from the 8 data lines.
|
|
|
|
|
|
Hi CPians,
following code does work:
BOOL b4=CreateDirectory("C:\\hop",NULL);
following does not work (I have deleted the hop previously created by the previous code line, so the start point is the same):
BOOL b4=CreateDirectory("C:\\hop\\hop\\hop",NULL);
GetLastError returns 3, which states "The system cannot find the path specified." which is in this especially true, since I would like to create the directory
Does CreateDirectory not support multiple level creation ? If not, are there any alternative solution to it ?
Do I have to use specific security attributes ? If yes, how can I retrieve them (like the ones currently set for the system) ?
Do you think following is possible with CreateDirectory :
BOOL b4=CreateDirectory("\\server.hop.com\\hop\\hop",NULL);
Thanks for all
~RaGE();
|
|
|
|
|
The documentation for CreateDirectory[^] does mention that it will only create the final directory in the specified path (c.f. the comments for ERROR_PATH_NOT_FOUND).
There is a suggestion at the MSDN site to use the SHCreateDirectoryEx function. However, the documentation for this function would indicate that it won't work on earlier versions of Windows.
The alternative is to parse your path string (for the '\\' or '/' characters) and create the intermediate directories as well. You can use CString to locate the first occurrence of the character, do a SetCurrentDirectory and, if that fails, CreateDirectory. Repeat this process until you've parsed all subdirectories in the path string.
Bob Ciora
|
|
|
|
|
I'm trying to get a textbox that I can immediately start typing into.
Currently, I have to click in the window before the cursor shows up then allowing me to enter text. Any suggestions? I've tried using ShowWindow(TEXTMOVE,SW_SHOW) and SetForegroundWindow(TEXTMOVE)and other things in my DoReturnStuff subroutine, but nothing has worked.
Attched is my code:
#include <windows.h>
#define WIN32_LEAN_AND_MEAN
#define DIRECTIONS 1000
#define TEXT_ENTRY 1001
#define ADD_BUTTON 1002
static HINSTANCE hInstance = NULL;
char szClassName[] = "iotest";
static HWND TEXTMOVE;
void DoReturnStuff()
{
UINT TextLength = GetWindowTextLength(TEXTMOVE);
LPTSTR ItemText = new TCHAR[TextLength + 1];
GetWindowText(TEXTMOVE, ItemText, TextLength + 1);
MessageBox(NULL, ItemText, "you pressed enter:", NULL);
SetWindowText(TEXTMOVE,NULL);//ERASES TEXT IN TEXTBOX
// ShowWindow(TEXTMOVE,SW_SHOW);//trying to make cursor appear
// SetForegroundWindow(TEXTMOVE);//trying to make cursor appear
delete[] ItemText;
return;
}
LRESULT CALLBACK inputoutput(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
switch(message){
case WM_CREATE:
CreateWindow("STATIC", "Enter text:",
WS_CHILD | WS_VISIBLE,
70, 20, 150, 20,hwnd, (HMENU)DIRECTIONS, hInstance, NULL);
CreateWindow("BUTTON","Add Name", WS_CHILD | WS_VISIBLE,
105, 90, 80, 30,hwnd, (HMENU)ADD_BUTTON,hInstance,NULL);
TEXTMOVE = CreateWindow("EDIT","enter key",WS_CHILD | WS_VISIBLE,
35, 50, 55, 100, hwnd, (HMENU)TEXT_ENTRY, hInstance, NULL);
SendDlgItemMessage(hwnd, TEXT_ENTRY, WM_SETFONT,
(WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0));
break;
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED){
if(LOWORD(wParam) == ADD_BUTTON){
DoReturnStuff(); } }
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
break;
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nCmdShow){
HWND hwnd;
MSG talkbacktome;
WNDCLASSEX usefulstuff;
usefulstuff.hInstance = hInstance;
usefulstuff.lpszClassName = szClassName;
usefulstuff.lpfnWndProc = inputoutput;
usefulstuff.style = CS_DBLCLKS;
usefulstuff.cbSize = sizeof(WNDCLASSEX);
usefulstuff.hIcon = LoadIcon(NULL, IDI_WINLOGO);
usefulstuff.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
usefulstuff.hCursor = LoadCursor(NULL, IDC_ARROW);
usefulstuff.lpszMenuName = NULL;
usefulstuff.cbClsExtra = 0;
usefulstuff.cbWndExtra = 0;
usefulstuff.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
if(!RegisterClassEx(&usefulstuff)) return 0;
hwnd = CreateWindow(
szClassName,
"name sorting",
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT,
CW_USEDEFAULT,
275,
175,
HWND_DESKTOP,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd, nCmdShow);
while(GetMessage(&talkbacktome, NULL, 0, 0))
{
// dante shamest cpp-home.com forum jun 10 2004
if ((talkbacktome.message==WM_KEYDOWN)&&(talkbacktome.wParam==VK_RETURN))
{
DoReturnStuff();
}
TranslateMessage(&talkbacktome);
DispatchMessage(&talkbacktome);
}
return talkbacktome.wParam;
}
|
|
|
|
|