|
|
I want to open a non-existing file, and write to it and read from it without closing and re-opening.
open using CreateFile(). which parameters should be used for this function?
|
|
|
|
|
How about:
HANDLE hFile = CreateFile(..., GENERIC_READ | GENERIC_WRITE, ...);
WriteFile(hFile, ...);
SetFilePointer(hFile, ...);
ReadFile(hFile, ...);
CloseHandle(hFile);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I want to see what kind of connection a computer has. To this end I am using the InternetGetConnectedState function(if you have any better ideas I am all ears).
<br />
<br />
char * tip_de_conexiune(void)<br />
{<br />
char respuns[1024];<br />
<br />
DWORD tip_de_conexiune;<br />
<br />
InternetGetConnectedState(&tip_de_conexiune,0);<br />
<br />
switch(tip_de_conexiune)<br />
{<br />
<br />
case INTERNET_CONNECTION_LAN:<br />
{<br />
strcpy(respuns,"lan"); <br />
MessageBox(0,"lan","lan",MB_OK);<br />
}<br />
break;<br />
<br />
case INTERNET_CONNECTION_MODEM:<br />
{<br />
strcpy(respuns,"dialup");<br />
MessageBox(0,"modem","modem",MB_OK);<br />
}<br />
break;<br />
<br />
case INTERNET_CONNECTION_OFFLINE:<br />
{<br />
strcpy(respuns,"offline");<br />
MessageBox(0,"offline","proxy",MB_OK);<br />
}<br />
break;<br />
<br />
case INTERNET_CONNECTION_CONFIGURED:<br />
{<br />
strcpy(respuns,"configurat");<br />
MessageBox(0,"configured","proxy",MB_OK);<br />
}<br />
break;<br />
<br />
}<br />
MessageBox(0,"a","b",MB_OK);<br />
<br />
return respuns;<br />
}<br />
<br />
this works but it returns none of the predefined values either when I am on or offline. I have a dialup connection.
any other way of doing this?
or what is wrong with this?
|
|
|
|
|
Spiritofamerica wrote:
what is wrong with this?
Each of those values is a bit flag. The result contains one or more of them. If you use a switch on the result you are checking for each of them but excluding the possibility of combinations.
Try something like this instead:
CString sFlags;
if (tip_de_conexiune & INTERNET_CONNECTION_LAN)
sFlags += "Lan ";
if (tip_de_conexiune & INTERNET_CONNECTION_MODEM)
sFlags += "Modem ";
if (tip_de_conexiune & INTERNET_CONNECTION_OFFLINE)
sFlags += "Offline ";
if (tip_de_conexiune & INTERNET_CONNECTION_CONFIGURED)
sFlags += "Configured ";
AfxMessageBox(sFlags);
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
thanks man
it works now when I am online
it correctly shows modem configured as in the 2nd and 4th ifs in your code
but when I am offline it shows nothing it does not show offline
why is this man?
and everybody else that might know?
|
|
|
|
|
the return value is 0x12 always as I tested.
includeh10
|
|
|
|
|
how did you test includeh10?
|
|
|
|
|
UINT uValue=InternetGetConnectedState();
CString cs;
cs.Format("0x%X, %d",uValue,uValue);
MessageBox("Hello",cs,MB_OK);
-------------------------
I use broadband at home.
includeh10
-- modified at 19:55 Sunday 28th August, 2005
|
|
|
|
|
See here also.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi!
How do I calculate the value of dwBloblen of pbKeyBlob read from a file.Even if i use the number of byted read returned from the CFile read function the key import function fail.How does the know the receiving side know the size of KEYBLOB.
////read KEYBLOB from a received file
CFile file;
BYTE *pbKeyBlob1 = NULL;
DWORD dwBlobLen1=512; //just for testing but doesnt work for RSA
//signature
pbKeyBlob1 = (BYTE*)malloc(dwBlobLen1);
// Read the key BLOB from the file.
if(file.Open("key.txt",CFile::modeRead))
{
file.Read(pbKeyBlob1,dwBlobLen1);
file.Close();
}
// call CryptImportKey
if(CryptImportKey(
hProv,
pbKeyBlob1,
dwBlobLen1,
0,
0,
&hPubKey))
{
MessageBox("The key has been imported");
}
else
{
MessageBox("The key import failed");
}
|
|
|
|
|
|
Have some legacy code generator (EZbuilder) which reqires Visual v 1.52. Where can I get a copy?
|
|
|
|
|
It's difficult to get 6.0 let alone 1.52. I reccommend you port your code to a current compiler.
Elaine
The tigress is here
|
|
|
|
|
Ver. 1.52 was the last version of the Win 3.1 (16-bit compiler). It was include with the release of VC Ver. 4.0.
You need to bring the code upto date.
It's not that difficult, just time consuming.
The MSDN covers the subject of updating 16-bit programs to 32-bit, some where.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
It is possible that the code runs under a DOS enviornment, so a newer compiler will not help. Does MSDN still provide the legacy archive?
Steve
|
|
|
|
|
Steve Mayfield wrote:
It is possible that the code runs under a DOS enviornment
With a name like EZBuilder, it probably wasn't DOS. If it was then it should have been written according to the standard, in which case it should still compile as a console application. The only problem you may run into under that is modern system security for hardware access.
If it was written for DOS, then the whole interface needs to be rewritten anyway.
Steve Mayfield wrote:
Does MSDN still provide the legacy archive?
Many of the examples (and samples) you see in MSDN are written in C, there's your legacy archive. Most of the code I wrote years ago for DOS still compiles and works today (still supported).
Note: Many of the examples are the same ones that where in the help file for both Ver. 1.0 and 1.52 of the compiler.
If you seperated most of the code that does the work from the interface code that shows it to the user, then you should still be able to use that same code.
The conversion requires: you to handle some messages differently and some functions are no longer supported.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I seem to recall seeing a C++ instructional book that came with v1.52 on a CD, that might be the easiest way if you can't find a release online.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
I'm trying to use MSXML 4 DOM to parse a xml document in Visual C++, but without success. A snippet of the xml structure is a following:
<code>
<data>
<album label="Album title 1">
<track label="Label 1" sndUrl="1\0.jk" txtUrl="1\0.jk"/>
<track label="Label 2" sndUrl="1\1.jk" txtUrl="1\0.jk"/>
</album>
<album label="Album title 2">
<track label="Label 1" sndUrl="2\0.jk" txtUrl="2\0.jk"/>
<track label="Label 2" sndUrl="2\1.jk" txtUrl="2\0.jk"/>
</album>
</data>
</code>
Can anyone give me a code snippet to parse album label, track label, sndUrl, txtUrl attributes to a CString?
Please help!
Thanks in advance for any answers.
|
|
|
|
|
johnnyXP wrote:
I'm trying to ..., but without success.
What is the problem ? You don't know what to start from ? Or you can not look at MSDN , where MSXML interfaces are well documented ? Or you have some kind of errors ?
If you have you own code, which is not working, you can post a fragment.
Andrew
|
|
|
|
|
I have the MSXML SDK documentation. Actually i can't understand how to iterate throw all "album" nodes and also how to iterate within an album node to get all tracks...
I have do the same job in C# with .NET framework, but i can't in MSXML ...
|
|
|
|
|
documentElement property of IXMLDOMDocument will return you code tag. Then you need to use firstChild property of IXMLDOMNode to get data node. And again the same to get first album node. Having album node you can use it's nextSibling property to get next album node. So, I hope it's clear how to get all albums and tracks.
By the way, you can use selectSingleNode("/code/data/album") from you document node.
Having IXMLDOMNode you can query IXMLDOMElement interface and its getAttribute method.
With best regards,
Andrew
|
|
|
|
|
|
MYSQL*pMySQL=mysql_init((MYSQL*)0);
if(pMySQL==0) return;
MYSQL*pConnect=mysql_real_connect(pMySQL,
"www.mysite.com",//site name
"mysite_user", //user name
"password", //password
"mysite_maindb", //database name
0,0,0);
mysql_error says:
Access denied for user: 'mysite_user@60.246.13.57' (Using password: YES)
the user, password and database have no problem because they are all work in php (as localhost).
please help me for finding problem.
includeh10
-- modified at 8:50 Saturday 27th August, 2005
|
|
|
|
|
Try setting the password for the MySQL user to an empty string (i.e. no password), and then change your program accordingly. If you get a connection the problem may be caused by a version mismatch. Take a look at this MySQL article which talks about 'old_password' function.
|
|
|
|