|
I'm getting an access violation in my code when I'm creating a dial entry in the default phonebook. I've tried so many different ways to load the data into the operators that are being passed to the RaasSetEntryProperties that I think I've gotten to buried in the problem and need to post it for some help. I'm a rookie, so if there is other portions of my code below, please feel free to school me. I've debugged enough with stop point that I know that the RasSetEntryProperties call is causing the error within the RASAPI. I am calling the funtion from the constructor of a class I'm creating, if that helps.
LPRASENTRY myRasEntry = new RASENTRY;
myRasEntry->dwSize = sizeof(RASENTRY);
lstrcpy(myRasEntry->szLocalPhoneNumber, "6479008" );
lstrcpy(myRasEntry->szDeviceName, TheDeviceName);
lstrcpy(myRasEntry->szDeviceType, "RASDT_Modem");
myRasEntry->dwFramingProtocol = RASFP_Ppp;
myRasEntry->dwfNetProtocols = RASNP_Ip;
myRasEntry->dwfOptions = 0;
myRasEntry->dwfOptions = RASEO_IpHeaderCompression | RASEO_ModemLights | RASEO_SwCompression;
myRasEntry->dwType = RASET_Phone;
//Create Phonebook entry called "Remote"
//DWORD dwAnotherBufferSize = sizeof(RASENTRY);
DWORD dwAnotherBufferSize = 0;
char ConnectionName[7] = "Remote";
(void) RasGetEntryProperties(NULL, NULL, NULL, &dwAnotherBufferSize, NULL, NULL);
dwErr = RasSetEntryProperties(NULL, &ConnectionName[7], myRasEntry, dwAnotherBufferSize, NULL, 0);
Thank you,
Chuck Foster
|
|
|
|
|
cfo5ter wrote: lstrcpy(myRasEntry->szDeviceType, "RASDT_Modem");
RASDT_Modem is a macro defined in Ras.h #define RASDT_Modem TEXT("modem") so do not put it in quotes.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Also I noticed that you are not setting all the RASENTRY variables that you are not using to zero. They will have random values in them and that could also be the cause of your problem.
LPRASENTRY myRasEntry = new RASENTRY;
memset (myRasEntry, 0, sizeof(RASENTRY);
...
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
That was the ticket. Thank you so much. Lesson learned. memset enterred into my mind for use everywhere. Oddly it does not create an entry titled "Remote" but I will figure this out.
By the way, I changed the string problem as well.
Thanks again,
Chuck
|
|
|
|
|
cfo5ter wrote: Oddly it does not create an entry titled "Remote" but I will figure this out.
dwErr = RasSetEntryProperties(NULL, &ConnectionName[7],
Why are you passing in the address of the terminating NULL when you want the address of the string?
dwErr = RasSetEntryProperties(NULL, ConnectionName,
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
It did want the address of the string. The 7 index was a rookie mistake of mine. The final line that created the entry I wanted with the name I wanted was:
dwErr = RasSetEntryProperties(NULL, &ConnectionName[0],
I'm good to go,
Thank you,
Chuck
|
|
|
|
|
In C/C++ using the name of an array, ConnectionName in this case, is the same as using the address of it's first element, &ConnectionName[0]. So the standard way is to just use the array name.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
hey all,
So I am reading a file into a char buffer[] and need to combine two of the values in the buffer into an int value. The Documentation for my device says that values 5 and 6 in the array are one value with MSB first. How can I put these values into an int?
thanks
- legit
|
|
|
|
|
lets assume that u have a buffer of type (char *) called charbuffer
you can convert it like this (I havent tested it but it should work):
short *intbuffer = (short*)charbuffer;
now every consecutive two chars in charbuffer will be treated as 1 short (16-bit) integer in intbuffer.
regards
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Mohammad A Gdeisat wrote: short *intbuffer = (short*)charbuffer;
now every consecutive two chars in charbuffer will be treated as 1 short (16-bit) integer in intbuffer.
FYI that won't work on an Intel x86 machine in his case because the most significant byte is
FIRST in the char array.
Mark
|
|
|
|
|
then u can use masking and shifting to swap between hi-order and low-order bytes.
Regards,
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
const char* str_int = "777";
int i = atoi(str_int);
Convert a string to integer.[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
int intvalue = ((buffer[5] << 8) | buffer[6]) & 0x0000FFFF;
Edit: Forgot a parenthesis
|
|
|
|
|
Please help me write a simple Dialog base that can load an image to a frame
|
|
|
|
|
You can use LoadImage or CImage class for load an image
|
|
|
|
|
Hi guys,
I create a popup context menu dynamically and this menu can contain many sub menus. I use InsertMenu function like this:
Menu.InsertMenu(i,MF_BYPOSITION,ID_FAV_BASE+i,element.strQuickName);
the problem is that the created menu is disabled, I want to handle the message in the OnCommand() handler, but when I call TrackPopupMenu() the added menu items are just disabled and I dont know how to enable them.
Thanks
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
See CMenu::EnableMenuItem()
In MFC you can use the command enablers in the parent window as well...
See ON_UPDATE_COMMAND_UI, ON_UPDATE_COMMAND_UI_RANGE, etc.
|
|
|
|
|
No, it is not. The menus were disabled by the MFC framework because the have no message handlers for their associated IDs.
The strange thing is that I create the same menu Items with the same IDs twice, once as a menu attached to the main window, and once as a context menu, those that are attatched to the main window work flawlessly, but those that are used as context menu are always disabled!!!
Any idea?
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Right. Like I stated, use command enablers in the window the menu is "attached" to.
Mark
|
|
|
|
|
Is EnableMenuItem helpfuls?
|
|
|
|
|
No, it is not. The menus were disabled by the MFC framework because they have no message handlers for their associated IDs.
The strange thing is that I create the same menu Items with the same IDs twice, once as a menu attached to the main window, and another time as a context menu, those that are attatched to the main window work flawlessly, but those that are used as context menu are always disabled!!!
Any idea?
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
void APIENTRY omfg_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
if (MODELS_1)
{
show_damn_modelz();
}
if (MODELS_2)
{
show_damn_modelz();
}
if (MODELS_3)
{
show_damn_modelz();
}
if (MODELS_4)
{
show_damn_modelz();
}
(glDrawElements)(mode, count, type, indices);
}
/////////in opengl.h i have this
#pragma comment(lib,"OpenGL32.lib")
#pragma comment(lib,"GLu32.lib")
#pragma comment(lib,"GLaux.lib")
#include
#include
#include
void APIENTRY omfg_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
//////// in dll main
bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
hTtnDll = hDll;
DisableThreadLibraryCalls(hDll);
sycoreReDirectFunction("kernel32.dll", "GetProcAddress", (DWORD)&pGetProcAddress);
return TRUE;
}
return FALSE;
}
and this is how i wanna detour it
DETOUR_TRAMPOLINE(void WINAPI glDrawElements_Trampoline(GLenum, GLsizei, GLenum, const GLvoid *indices), glDrawElements);
void WINAPI glDrawElements_Detour(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{
// ur code
glDrawElements_Trampoline(mode, count, type, indices);
}
//////////////////////
bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
DetourFunctionWithTrampoline((PBYTE)glDrawElements_Trampoline,(PBYTE)glDrawElements_Detour);
hTtnDll = hDll;
DisableThreadLibraryCalls(hDll);
sycoreReDirectFunction("kernel32.dll", "GetProcAddress", (DWORD)&pGetProcAddress);
return TRUE;
}
return FALSE;
}
but i get errors and i dont know what should i do with the void APIENTRY functions ? please anyone could help me ?
|
|
|
|
|
|
See here[^] and here[^]
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
When I saw first link on status bar I guess its acquainted both of them are nice
|
|
|
|
|