|
thanks!
i have got it~
i use WinExec(strCmd, SW_HIDE); in stand of the system();
it works !
|
|
|
|
|
jakeyjia wrote: i use WinExec(strCmd, SW_HIDE); in stand of the system();
Havn't you seen Note in MSDN documentation for this API ?
Note This function is provided only for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function.
|
|
|
|
|
i see~ but it works? why?
|
|
|
|
|
CreateProcess(), WinExec(), ShellExecute() are ok
system() works, but exists for backward compatibility with 16bit applications. you shouldn't use it
|
|
|
|
|
Its there for backword compatability.
And , why dont use enhanced robhust version for same purpose ?
|
|
|
|
|
Hi, I have a VC6 program that includes heavy use of serial communications. My problem is that when a serial connection is live and the computer enters sleep mode the computer becomes unpredictable - freezing when sleep is intiated, or refusing to come out of sleep mode.
If I first manually close the COM port(s) then let the computer go to sleep (or hibernate) then everything works as expected.
So my question is, is there any way I can detect when sleep (or hibernate) mode is being entered from code in my program (so I can force a close of the COM ports)? And similarly to identify when the computer is waking up (so I can reopen the COM ports)?
Appreciate any help...
Simon.
|
|
|
|
|
|
Thanks Xing,
This appears to be exactly what I'll need ... back to coding!
Cheers, Simon.
|
|
|
|
|
Is there a way to import an object created with a 3d-modeling program (ex. Google Sketchup) to an OpenGL application and use it?
If yes what file type must it be (.obj?) and how?
I'm new at this
|
|
|
|
|
Try asking this on the graphics forum. I don't know about openGL but I know Direct3D has adapters/plugind/convertors for many of the popular 3Dmodelling softwares file formats. I'm sure OGL has the same.
|
|
|
|
|
Right, I didn't see that forum. thanks
|
|
|
|
|
I'm calling:
Graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
but still it doesn't work. My Metafile object is drawn without antialiasing.
Does anyone know why?
Thanks!
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Hello,
I am doing a conversion of a unsigned --int64 to binary using 2003 and does not seem to work. This code works with VC++ 6.0.
In My header file i define a structure
#define QWORD unsigned __int64
#define NUM_EVENTS 53
struct SList // sl
{
int idObject;
int EMPTY_OBJECT_ID;
BOOL aEvents[NUM_EVENTS];
SList() : idObject(EMPTY_OBJECT_ID)
{ ::memset(aEvents, 0x00, sizeof(aEvents)); }
SList(int id) : idObject(id)
{ ::memset(aEvents, 0x00, sizeof(aEvents)); }
SList(int id, QWORD qwEnabled)
{
SList();
idObject = id;
for (int i = 0; i < NUM_EVENTS; i++)
aEvents[i] = 0 != (qwEnabled & (QWORD)(1 <<
(QWORD)i));
}
};
In My cpp file i am populating a temporary list,
int id =12345;
QWORD qEnable = 9007191738548223;
CArray <SList*, SList*> aSList;
SList* psl = new SList(id, qEnable);
// Add them to a temporary list.
aSList.Add(psl);
Anyone having any idea whether there is any patch to rectify? Pls help
Anil
|
|
|
|
|
What is the problem that is occuring?
What if you use the LL suffix on your QWORD literals...
for (int i = 0; i < NUM_EVENTS; i++)
aEvents[i] = 0 != (qwEnabled & (QWORD)(1LL <<
(QWORD)i));
Also have you applied SP1 to VS2003?
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
That Worked, thanks alot.
|
|
|
|
|
Hello all
Im having an issue with trying to write a class that allows me to create a method for socket handle reuse but its not working so good I can always create the directory but when I goto write the file I get handle invalid errors(specifically the hConnectionHandle), its definately a handle issue. Im thinking im missing some obvious and important step here can anybody help, here is the basic pseudo code of what im trying to do.
I do not have my original code to post for Debug, but below shows all the steps I took to try and reuse the HANDLES minus any exception handling and debugging routines. Im trying to see if anyone has done something like this before and can point out where I'm missing a step or off base or what?
again the error always was an invalid handle (hConnectionHandle)on second reuse in WriteFile each and everytime.
class FTPjunk
{
public:
FTPjunk();
HINTERNET hOpenHandle;
HINTERNET hConnectionHandle;
bool SetHandles(string mode);
bool CreateDirectory(string directory_name);
bool FTPjunk::WriteFile(string file_name);
private:
~FTPjunk();
};
FTPjunk::FTPjunk()
{
hOpenHandle = null;
hConnectionHandle = null;
}
FTPjunk::~FTPjunk()
{
}
bool FTPjunk::SetHandles(string 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") {
InternetCloseHandle(hOpenHandle);
InternetCloseHandle(hConnectionHandle);
}
}
bool FTPjunk::CreateDirectory(string directory_name);
{
SetHandles("OPEN");
FtpCreateDirectory(hConnectionHandle, directory_name);
SetHandles("CLOSE");
return true;
}
bool FTPjunk::WriteFile(string file_name);
{
SetHandles("OPEN");
FtpPutFile(hConnectionHandle,
file_name,
file_name,
dwflags,
0);
SetHandles("CLOSE");
}
}
int main()
{
FTPjunk ftpjunk = new FTPjunk();
ftpjunk->CreateDirectory("test_directory");
ftpjunk->WriteFile("test_file");
return 0;
}
-- modified at 15:13 Monday 26th February, 2007
|
|
|
|
|
I can't see anything that should cause a reuse problem here.
I would recommend switching the InternetCloseHandle() calls (close the hConnectionHandle first)
and set the handles back to null after they are closed.
Then use the debugger and step through to find the call that is failing and why (using
GetLastError())
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
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.
|
|
|
|