|
yeah I know and it worked part of the time, Ill try what you said reversing the order and resetting to null, appreciate it I post what i find
AJ
|
|
|
|
|
Big upps to Mark, that worked like a champ I knew it was some stupid thing I was overlooking my code and I both thank you.
Here was the change I did:
bool FTPjunk::SetHandles(char * mode)
{
if(mode == "OPEN") {
hOpenHandle = InternetOpen(lpszAgent,
dwAccessType,
lpszProxyName,
lpszProxyBypass,
dwFlags);
hConnectionHandle = InternetConnect(hOpenHandle,
lpszServerName,
nServerPort,
lpszUsername,
lpszPassword,
dwService,
dwflags,
0);
}
else if(mode == "CLOSE") {
<font color=red>InternetCloseHandle(hConnectionHandle);
InternetCloseHandle(hOpenHandle);
hConnectionHandle = NULL;
hOpenHandle = NULL;</font>
}
}
|
|
|
|
|
That was really a lucky guess.
I just think it's a good idea to free objects in reverse order of creation when one of the
objects depends on the other for its creation (ie InternetConnect needs a handle from
InternetOpen). Especially with "handles", with which there's no way of knowing what goes on
behind the scenes in a seemingly simple "CloseHandle" call.
Setting to NULL is just generally considered good form (unnecessary in destructors for member
variables) and more importantly, it makes it easier to debug - NULL values are easily spotted
while debugging, invalid handle values are extremely hard to spot
I'm glad it worked for you!
Cheers,
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I am trying to access a dll from vc++ code using the below code.
typedef BOOL (CALLBACK* GetUserNameA)(LPTSTR,LPDWORD);
HINSTANCE hDLL; // Handle to DLL
GetUserNameA lpfnDllFunc1; // Function pointer
LPTSTR dwParam1=(LPTSTR)" ";
LPDWORD uParam2=(LPDWORD)32;
BOOL uReturnVal;
hDLL = LoadLibrary("F:\\DLL\\advapi32\\advapi32.dll");
if (hDLL != NULL)
{
lpfnDllFunc1 = (GetUserNameA)GetProcAddress(hDLL,
"GetUserNameA");
if (!lpfnDllFunc1)
{
// handle the error
FreeLibrary(hDLL);
//return SOME_ERROR_CODE;
}
else
{
// call the function
uReturnVal = lpfnDllFunc1(dwParam1, uParam2);
}
}
But when i call the function as uReturnVal = lpfnDllFunc1(dwParam1, uParam2);
I get an access violation error. Could someone give me a hint regarding what could have went worng.
Vin
|
|
|
|
|
vinith wrote: Could someone give me a hint regarding what could have went worng.
You are passing a pointer to a buffer that is only 2 characters long, yet you pass 32 as it's
length. Chances are pretty good the function is trying to overrun the end of your buffer.
Also the second parameter is expecting a pointer to a DWORD. "LPDWORD uParam2=(LPDWORD)32;"
creates a pointer to address 32 which is invalid.
Either of the above two problems will most likely cause an access violation.
Try:
TCHAR szParam1[32]={0};
DWORD uParam2 = 32;
...
uReturnVal = lpfnDllFunc1(szParam1, &uParam2);
*EDIT* Actually you are forcing the call to the non-Unicode API so it should be:
char szParam1[32]={0};
DWORD uParam2 = 32;
...
uReturnVal = lpfnDllFunc1(szParam1, &uParam2);
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
|
vinith wrote: I get an access violation error.
What call stach says about this ?
|
|
|
|
|
Hi all
I have a ActiveX control which is to be used with MS Access. Now my question is that does the control tested with MS access 97 will work fine with all the later versions of MS access?
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
With just the information you've provided, you're the only one in a position to answer such a question. Does your control use something specific to Access 97?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have created a program for carpet factory which ask user all the detail and then stores the final quotation to the file, which can be displayed later.
The following function reads file and counts the number of entry and return the count to main to sort out reference number, reference number starts from 1000 and now every time user input data, next reference number should be provided.
int FillCustomersArray()
{
const int BUFF_LEN = 256;
char Buffer[BUFF_LEN];
fstream InFile;
CustNum = 0;
InFile.open("Quotes.txt", ios::in);
if(InFile.is_open())
{
while(!InFile.eof())
{
InFile >> ws;
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].QuoteNumber = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
strcpy(Customer[CustNum].Name, Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].DeliveryCost = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].CarpetCost = atoi(Buffer);
InFile.getline(Buffer, BUFF_LEN);
Customer[CustNum].Guarantee = atoi(Buffer);
CustNum++;
}
}
InFile.close();
return CustNum;
}
Everything is working allright, except this small error...just have look to below stored file..
1005
Rotton J
3840.00
2536.00
5
1006
Brocket L
1100.00
0.00
11000
1007
gbush
1452
0
1
1009
gibson
2772
0
1
1010
BOB MARTIN
2772
1108.8
1
1011
JACOB
6006
1108.8
2
The first number is reference number, so till 1006 its all fine as these details were already existed in file and now 1007 is inputed correctly but after this the reference 1009 is taken and leaving 1 more line. So the gap between quotes is increased by 1 line and 1008 reference number is not used. And now all numbers would go in sequence but the space has increased to two white lines...
Daoes anybody know whats going on here.
I know its quite simple problem but i am not able to get hold of it...
Thanks a lot
|
|
|
|
|
Hmm, that function looks well. Maybe the file contains exacly what you've got after reading it. Maybe problem occured during saving the file. Have you looked into the file with for example notepad.exe to see what it contains? Have you tried to use debugger? And try to give us some more details.
|
|
|
|
|
yeh i used debugger and its reading white space as a input giving 0 value to every field and steping to reference 1009 and from here onwords its fine with 2 white line gap.....
If you want i can post my main() here ...
thanks
|
|
|
|
|
Its very strange behaviour. I would have to run this project on my computer to see what happens. I can't tell you what's wrong just from your description.
Why the "1008" is so different? What is so special about this?? You didn't give me the answer if the file really contains fields:
1008
blabla
.
.
.
blabla
Maybe there is no 1008 case? Maybe the file contains just white space in that raw?
I've created Quotes.txt and pasted your list adding position/case 1008 and making 1 white space between each case. Then I've pasted your code to my simple reading from that file program, and everything was ok. Whole file was read properly. So again maybe your file has got some wrong items written earlier.
|
|
|
|
|
Hi
I have a activex control developed in VC++.
The graphics in the control is created using GDI. Now I want the windows XP themes to be applied to this control also.
What is the best way to do it.
Am not deriving the control from any Control class.
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I would suggest looking into the DrawTheme*(...) functions, and other Theme-related functions, and use them to get the active Theme and draw the "theme-able" parts of your control(s).
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thank you very much.
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I have developed an application in VS 2005.
It is giving the following error when i click a button on the form.
An Unhandled Win32 exception occured in abc.exe[2572]
with the title "Visual Studio Just-In-Time Debugger"
What may be the problem? What does the number 2572 signify?
Thanks
|
|
|
|
|
The problem is likely a programming error. Let the debugger attach to the process so you can see where the problem is.
The number after the executable is the Process ID (PID) for the running process.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
The best way to find the problem instead of guessing what might happen is simply to debug your application. Start your debugger (press F5) and see where the crash occurs. You can also check the call stack to track the problem.
You should really learn to use your debugger. It is a very powerful tool and it is much more accurate and faster than asking such a question on a forum.
|
|
|
|
|
Thank you so much.
But the problem is only with the release version and not the debug version.
|
|
|
|
|
Turn on the highest warning level (always a good idea, anyway), and look for things like uninitialized variables, and pay particular attention to any buffers used - ensure that the buffer's length is always being respected.
Debug builds often "pad" allocated heap and stack memory to look for overruns. You should run a debug build to completion (exit the process normally, do not stop it in the debugger) to see if you notice any buffer-related issues.
Another possibility is mixing of debug and release builds of any libraries and/or DLLs. This is sometimes a good reason to suffix the name of any debug binaries with something like D , so MyDLL.dll becomes MyDLLD.dll , so that this is harder to have happen.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
anyone know objectuve c
i have to draw the application window ie our user interface control dilaog to full screen. i dont know how to write this.
anyone who knows please help me.
thanx in advance
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
What platform/compiler are you using ? I don't think Microsoft support Objective C in any of their IDE and compiler.
Is it a Mac/OSX application ? something on Linux ?
|
|
|
|
|
how can i display the bmp, jpg, png image files as a thumbnails on MyListView.
this is my code in ListView class:
HANDLE hFile;
hFile = CreateFile( "C:\\Documents and Settings\\B.Srinivas\\My Documents\\My Pictures\\SkinDlg.bmp",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );
if( hFile == INVALID_HANDLE_VALUE )
{
MessageBox( "Invalid Handle", "ERROR", MB_ICONERROR);
}
else
{
// MessageBox( "File Opened successfully");
BYTE *Buffer;
DWORD p=SetFilePointer( hFile, 0x003, NULL, FILE_BEGIN );
Buffer = new BYTE [2359350];
//LPDWORD lpNumberOfBytesRead = NULL;
DWORD pp;
bitmap.bmType=0;
bitmap.bmWidth=1024;
bitmap.bmHeight=768;
bitmap.bmWidthBytes=1024;
bitmap.bmPlanes=1;
bitmap.bmBitsPixel=1;
bitmap.bmBits=(LPSTR)Buffer;
Bitmap image((WCHAR*)Buffer ,0);
Bitmap *bmPhoto = NULL;
CBitmap Bmp1;
Bmp1.SetBitmapBits(&bitmap,Buffer)
bmPhoto = new Bitmap( THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
// bmPhoto->SetResolution( 100,100);//image.GetHorizontalResolution(), image.GetVerticalResolution() );
//bmPhoto->SetResolution()
hBmp=CreateBitmapIndirect((BITMAP FAR*)&bitmap);
CDC *cdc=GetDC();
CDC *pMemDC=new CDC;
pMemDC->CreateCompatibleDC(cdc);
CBitmap *pOldBitmap=((CBitmap*)pMemDC->SelectObject(hBmp));
cdc->BitBlt(0,0,1024,768,pMemDC,0,0,SRCINVERT);
pMemDC->SelectObject(&pOldBitmap);
delete pMemDC;
}
please help me..
Regards,
Srinivas
|
|
|
|
|
I had to do this with an older reporting application I worked on - it dynamically loaded images from a database in the background and rendered them as thumbnails into a ListView control.
The way I did it was to use custom draw with the ListView control, combined with a ImageList control. The ImageList control was used to pre-create (pre-allocate) and manage a very large bitmap, and the thumbnails were dynamically copied into it by loading the images and drawing them into the individual "icon cells" in the ImageList control.
The ImageList control was then used to do indirect drawing directly into the ListView control using Custom Draw.
I was able to get a pretty large amount of Thumbnails to work this way.
I cannot release the code for it, but the concept for it is not patented!
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> 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! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|