|
the following code works (though I cannot figure why do you want to do this kind of stuff...)
DLL side:
extern "C"
{
VARIANT WINAPI MyString(void)
{
unsigned char vst[21] =
{
0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
0x00
};
OLECHAR olec[21];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, (LPCSTR)&vst, 21, (LPWSTR) olec, 21);
VARIANT vt;
VariantInit( &vt );
vt.vt = VT_BSTR;
vt.bstrVal = SysAllocStringLen(olec, 21);
return vt;
}
}
VB side:
Private Declare Function MyString Lib "DllString" () As Variant
Private Sub Form_Load()
Dim n As Long
Dim p
p = MyString()
For n = 1 To Len(p)
Debug.Print Asc(Mid(p, n, 1))
Next
End Sub
and finally, the output (Immediate Window)
0
23
255
0
23
255
0
23
255
0
0
23
255
0
23
255
0
23
255
0
0
I have used VARIANT type to encapsulate the string because Visual Basic makes some kind of translation over the strings whenever it passes to Windows-Like API exported by DLLs.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello everyone!! i am transfering a large amount of data to a FTP server. in the process, if the FTP connection goes down, how can i detect the connection loss???
vijay.
|
|
|
|
|
Hi,
Check socket handle - usually it's not valid any more. You didnt write what do you use.
-----------
Mila
|
|
|
|
|
hello sir,
sorry that i didnt write what i am actually doing. i am using CFtpConnection Class and using Putfile() function i am uploading the files to FTP server. but i want to know how to detect the connection loss (if any) while transfering the files. should i have to ping the server at certain time intervals or is there any other way of detecting the connection breakdown.???
vijay.
|
|
|
|
|
Hi,
No, pinging does tell you nothing because e.g. server can disconnect your session in any reason but its own will still working.
Add callback function to your code and check events CInternetSession::OnStatusCallback.
-----------
Mila
|
|
|
|
|
ok sir, thanks a lot.
vijay.
|
|
|
|
|
I'm looking for best C++ compiler. there are many but I don't know which is better?. borland or microsoft, which ver?
sia swar baluch
|
|
|
|
|
To be able to answer, we need to know what you mean by 'best' ?
There is no 'best' compiler, it's just a matter of choice.
|
|
|
|
|
I mean the better compiler,some compiler donot support some code's.
I mean which compiler isin use of great programer and wich ver(new or old) I have a borland C++ 5.2 and a 5.5 (can I finde better of these)
siaswar baluch
|
|
|
|
|
siaswar wrote: I mean the better compiler,some compiler donot support some code's.
That doesn't make any sense. If you try to compile a MFC program with a Borland compiler, chances are that it will fail. But the opposite is true also: if you try to comile a program that use libraries from borland with a microsoft compiler, it won't work neither.
That doesn't mean that Borland is better or worse than visual C++.
|
|
|
|
|
Hi friends,
I am facing very strange problem. My dialog box is not getting displayed on the screen.
Here are the steps what I am doing:
1. Adding on dialog thru the resource
2. Adding class to that dialog using class wizard, say the class name is CDlgGamma.
3. Adding one button in menu, and the function for that button in the application DOC.
4. Adding the DlgGamma.h in the DOC cpp file say “#include DlgGamma.h”
5. on button click function I am creating the object of the dialog and doing DoModal() like following
CDlgGamma dlgGamma;
dlgGamma.DoModal();
6. Now when I am compiling the application I am not getting any error
7. After running the application when I am clicking on the menu button I am not getting my dialog displayed, but if I press the "ALT" key of the keyboard the dialog gets displayed.
I don’t understand why this is happening in my application. Because If I create new application and do the same thing then it’s working fine.
Please help me out, need the help from forum
Thanks in advance,
-Dinesh.
-- modified at 2:02 Monday 18th December, 2006
|
|
|
|
|
Does anybody know of an article or guide for converting asm code to C code? I have a very small function in asm which I would like to add to my own code. I know it's possible to add the asm directly, but I would like to convert it to something more readable.
|
|
|
|
|
Hi,
I don't know if there are utilities to convert from assembly to c, but regarding putting assemble directly in your code you can do it:
_asm<br />
{<br />
}
Regards,
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
hi,
i need to knw how to initialize and use this control in a dialog based application can ne body help me.
i hav created a dialog and dragged and dropped richedit control wen i debug i dnt get the dialog on the screen.
can ne body help me,
thanx in advance,
zari
|
|
|
|
|
You need to call AfxInitRichEdit in InitInstance function of your application class, before displaying dialog box.
|
|
|
|
|
|
Hi All,
I have to develop CD/DVD writing software in VC++/MFC or in Win32/SDK, can any body help me how to develop this software ?If u have any idea tell me.
If you have idea to develop in other language tell me.
Please Help me.
Thanks and regards
Yudhisthira Attry
( yudhisthira.attry@gmail.com)
Yudhisthira Attry
|
|
|
|
|
IMO, the Nero API/SDK is a good way to go. The API itself is free, however, the users of your program must have a Nero licence. Check it out Here.[^]
Else, there is a built in burning software, IMAPI, (from Roxio, I think) in Windows XP. But as far as I know, it can't burn DVD's. There is a new version (2.0) i Vista, with extended functionality. Check it out Here[^]
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Have a look on Sourceforge[^] for such software, the source code is available on their projects.
Elaine
|
|
|
|
|
I think I saw example of write on cd on codeproject did you search?
|
|
|
|
|
I am trying to open a file using fopen for append and switching its current position using fseek to modify its current contents.
oFile=fopen(strcat(f_SELF,"1.exe"), "a+b");
fseek(oFile,f_POS,SEEK_SET);
putw(0x00000000,oFile);
fclose(oFile);
When I use fwrite on the file it returns a C0000005 exception and with the current code the new file info is appended to the bottom of the file instead of overwritten in the middle. How do I write to were my pointer is set?
|
|
|
|
|
From MSDN:
When a file is opened with the "a" or "a+" access type, all write
operations occur at the end of the file. The file pointer can be
repositioned using fseek or rewind but is always moved back to the end of
the file before any write operation is carried out. Thus, existing data
cannot be overwritten.
When the "r+", "w+", or "a+" access type is specified, both reading and
writing are allowed (the file is said to be open for "update"). However,
when you switch between reading and writing, there must be an intervening
fflush, fsetpos, fseek, or rewind operation. The current position can be
specified for the fsetpos or fseek operation, if desired.
So instead of using append mode try to use r+ it is for both reading and writing.
Hope this helps.
-- modified at 0:31 Monday 18th December, 2006
|
|
|
|
|
Using w+ overwrites the previous file, so I get an x size file because the data between 0x00 to where where fseek is set is filled with 0's and whatever was in fputw is at the end. I need to reserve the previous contents too.
|
|
|
|
|
"r+"
Opens for both reading and writing. (The file must exist.)
"w+"
Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.
If your file already exists,try using r+
|
|
|
|
|
I have a functioning Microsoft Visual C++ (6.0) application that uses both MFC (Microsoft Foundation Class) and COM (Component Object Model). I am trying to turn this application to a simple Win32 Console Application by getting a rid of any reference to MFC. When it is done, I would like to just compile it and run it from a command line instead of GUI.
The site didn't allow me to attach a zip file (120k). If you can help, please e-mail me and I will send you the zip file.
Thank you
Mohamed.
My e-mail: mohamed.douffir@monotypeimaging.com
|
|
|
|
|