|
pls help...another VC++ newbie here.
i tried to return string values from this particular dll im workin on thru BSTR. this return value shall be recievd by a VB application
this DLL im workin on is not a MFC dll but a win32 dll.
using the code block below...i tested if i could really
return a string thru BSTR, and it worked jst fine.
BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
but when i tried to return the values im really supposed to return ....i cant find a way to make it work.the program/dll must return the values of an array of unsigned char[].
heres what i did.
BSTR Message;
unsigned char vst[121];
vst[0] = 0x00;//these are the kind of values i expected it to return
vst[1] = 0x17;
vst[2] = 0xFF;
..
..(and so on..)
vst[20] = 0xFF;
CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( GETvst[10],pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
The code above shouldve returned the converted values of array GETvst[10] but only resulted wierd values i cant understand...i should be returning the values of array GETvst[10] to GETvst[16]....
ive read a lot of article abt this problem but cant find the solution
thnx in advance gurus
|
|
|
|
|
dekta wrote: BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
In the above code snippet is clear what you intend to do.
Below I'm not able to follow you anymore
dekta wrote: CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( GETvst[10],pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
What is GETvst[10] and what exactly do you want to do?
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.
|
|
|
|
|
pls help...another VC++ newbie here.
i tried to return string values from this particular dll im workin on thru BSTR. this return value shall be recievd by a VB application
this DLL im workin on is not a MFC dll but a win32 dll.
using the code block below...i tested if i could really
return a string thru BSTR, and it worked jst fine.
BSTR Message;
char *buff = "This works fine" ;
Message = SysAllocStringByteLen (buff , lstrlen(buff));
return Message;
but when i tried to return the values im really supposed to return ....i cant find a way to make it work.the program/dll must return the values of an array of unsigned char[].
heres what i did.
BSTR Message;
unsigned char vst[121];
vst[0] = 0x00;//these are the kind of values i expected it to return
vst[1] = 0x17;
vst[2] = 0xFF;
..
..(and so on..)
vst[20] = 0xFF;
CHAR theChar;
CHAR* pChar = &theChar;
res = VarI1FromUI1( vst[10] ,pChar);
Message = SysAllocStringByteLen (pChar, lstrlen(pChar));
return Message;
The code above shouldve returned the converted values of array GETvst[10] but only resulted wierd values i cant understand...i should be returning the values of array vst[10] to vst[16]....
ive read a lot of article abt this problem but cant find the solution
sorry for my previous typo errors gurus
|
|
|
|
|
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
|
|
|
|
|