|
Who told you the serial port uses the TCP/IP protocol ? Bury him.
Back to real work : D-25.
|
|
|
|
|
no no no.... I have another app to develop using the serial port and thought I could wet my feet with sockets writting it... just didn't know if sockets allow access to the serial port (still haven't read anything yet).
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
If I understand your question, you want to know if you can use sockets to communicate via the serial port. This depends on the serial connection.
Sockets let you communicate using TCP/IP. You can use TCP/IP over a serial connection (look up the SLIP and PPP protocols), but that requires that both ends of the connection use TCP/IP.
<assume_Windows_environment>
If you just need to send and receive arbitrary data via the serial port, then you have to use the builtin serial stuff: CreateFile() to open the port, ReadFile() and WriteFile() to read and write data, and so on.
</assume_Windows_environment>
Software Zen: delete this;
|
|
|
|
|
okay... that was what I wanted to know. I still haven't read up on sockets yet but sounds like its going to handle the TCP/IP well since you've implied it to be the default. That is a seperate issue from you question though... thanks for the response
Peace
-Mel
---------------------------------------------
The greenest grass is NOT on the other side of the fence, its the grass you take care of. Have you watered your lawn lately?
- Just remember when you point a finger at someone else, you are only one finger away from making a fist to hit them with!
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler <
|
|
|
|
|
hello,
i need a tip.
can somebody please tell me how can i include multilanguage support in my VC++ project? I need some of Serbian/Slovenian/Croatian characters to be recognized in Edit and List boxes as in these languages.
|
|
|
|
|
A simple way to manage it is to create as many .rc resource files as there are cultures. For instance appresources_slovenian.rc, appresources_croatian.rc, appresources_serbian.rc.
Then create as many build configurations so you have (Debug Serbian, Debug Slovenian, Debug Croatian, Release Serbian, Release Slovenian, Release Croatian). Each configuration will reference the appropriate .rc file.
Back to real work : D-25.
|
|
|
|
|
or, if you don't want to generate x number of applications, you can generate a DLL containing the resources and load it when the application starts.
You will then have another project only containing the different resources. I usually use one workspace containing all the projects files ( DSP ), one per language.
Max.
|
|
|
|
|
Thanks. Got that,but i am afraid that i was not very precise:my list and edit controls doesn't recognize local characters which are different from english:i can't for example to enter my real name in edit box 'cause it wont be recognized.It should be something like this:
Nikola Radovanović Mlađi
but it is not.Special letters are not recognized.
I think that i do not have appropriate dll file for serbian/slovenian/croatian language,and i dont know where to find it.maybe You know?
thanks.
|
|
|
|
|
- regarding the operating system, of course you must install the appropriate language. From what I know, both of the 3 languages you mention ar enot SBCS, but MBCS instead.
- if you are using the MFC dlls, be sure to use the appropriate mfcxxxloc.dll (where are the localized strings using by the MFC controls).
- and of course, you need to compile your code with the _MBCS switch (multi-byte).
Back to real work : D-25.
|
|
|
|
|
i was reading an article on ADO... and i have two questions about the code:
QUESTION 1:
_ConnectionPtr conptr(__uuidof(Connection));
I searched thru the code, and I cant find "Connection"...
why do we need a "connection pointer object" as opposed to a "connection object"
QUESTION 2:
ATL COM and ADO
--------------------------------------------------------------------------------
This article was contributed by Amit Dey.
Recently I did a project on online banking at NIIT, Bangalore. The project was coded mostly using VB with few ATL components thrown in, if only to teach us programming distributed applications. One middle tier component that I programmed was built with ATL and uses ADO to query the backend (SQL Server). Parts of that code appears here.
I assume the reader knows or at least has a fair idea about COM programming using ATL as well as ADO programming with VB.
What is ADO?
ADO standa for ActiveX Data Object.ADO provides an object-oriented programming interface for accessing a data source using the OLEDB data provider. It is the succesor to DAO and RDO object models and combines the best features DAO and RDO.
Programming OLEDB in C++ is easy. However, for languages like Visual Basic, that do not support pointers and other C++ features, implementing OLEDB is difficult.
This is where ADO really shines. ADO is an high level interface to OLEDB that is based on COM interfaces. Thus any application that supports COM can implement ADO.
ADO Features
Allows acess to all types of data
Supports free threading
Supports asynchronous queries
Supports client-side and server-side cursors
Supports disconnected recordsets
ADO Architecture
In the ADO model, we'll be using three main types of objects-
Connection
Command
Recordset
The Connection object sets up a connection to the data source. First, the data source name, its location, user ID, password etc is stored in a ConnectionString object, which is passed to the Connection object.to establish a connection to the data source.
The Command object is used to execute SQL commands, queries and stored procedures.
When a query is executed, it returns results that are stored in the Recordset object. Data in a recordset can be manipulated and then updated to the database.
Using ADO
First, we'll be building an ATL DLL component. This component has a method that takes one input parameter (customer ID in the project) and returns a reference to the corresponding Recordset object to the VB client. The client then displays the data in a form.
To create the DLL, use the ATL COM AppWizard to generate the framework for the application. Name the project FindCust and choose the server type as Dynamic Link Library.Also choose the option to support MFC library.
Insert a New ATL Object of type Simple Object to the project. Use the name Search in the Short Name textbox of the ATL Object Wizard Properties and click OK to add the object.
In classview, right click the interface name and add a method. Name the method SearchCust and type the following in the Parameters textbox :
[in] BSTR bstrcustid,[out,retval] _Recordset **ptr
Click the OK button to add the method.
Since the SearchCust method returns a reference to a Recordset object, we need to import the ADO library. To do this, open the file, StdAfx.h and add the following code :
#import "C:\Program Files\Common Files\System\ADO\MSADO15.DLL" rename_namespace("ADOCust") rename("EOF","EndOfFile")
using namespace ADOCust;
This step will help the Visual C++ compiler to understand the ADO objects defined in the type library, MSADO15.DLL. The rename_namespace function renames the namespace into which the DLL has been imported to the specified name. The rename option has been used to rename the EOF keyword to EndOfFile, because EOF is already defined in the standard header files.
Also the .idl file contains the method SearchCust which returns a reference to a Recordset object. To make the MIDL compiler understand the ADO objects, import the type library in the .idl file using the importlib statement in the library section (after importlib "stdole2.tlb") like :
importlib("C:\Program Files\Common Files\System\ADO\MSADO15.DLL");
Also move the interface definition in the .idl file to just after the importlib statement to make the MIDL compiler.understand ADO objects.
To do that, cut the interface definition block and paste it after the imporlib statement that was added. My interface definition block looks like:
[
object,
uuid(EB78D558-E071-4D25-80DD-41FD3519934E),
dual,
helpstring("ISearch Interface"),
pointer_default(unique)
]
interface ISearch : IDispatch
{
[id(1), helpstring("method SearchCust")]
HRESULT SearchCust([in] BSTR rcustid,
[out,retval] _Recordset **ptr);
};
Building the ATL Component
Now we are ready to code the SearchCust method to retrieve the corresponding information.What we need to do is :
Initialize the COM library
connect to the data source
execute the SQL commands
return the Recordset object
Uninitialize the COM library
Initialize the COM library :
CoInitialize(NULL);
To connect to a data source, first declare a Connection object pointer by passing the ID of the coclass.
_ConnectionPtr conptr(__uuidof(Connection));
Now call the Open function to establish a connection to the data source.
conptr->Open(_T("Provider=SQLOLEDB.1;
Data Source=SQLServer;
Initial Catalog=Customer"),
_T("user1"),
_T(""),
adOpenUnspecified);
but dont u have to specify a "database" name in addition to "Customer" table?
QUESTION: It's using SQL server based security. what about NT based login?
Thanks
norm
|
|
|
|
|
i was reading an article on ADO... and i have two questions about the code:
QUESTION 1:
_ConnectionPtr conptr(__uuidof(Connection));
I searched thru the code, and I cant find "Connection"...
why do we need a "connection pointer object" as opposed to a "connection object"
QUESTION 2:
conptr->Open(_T("Provider=SQLOLEDB.1;
Data Source=SQLServer;
Initial Catalog=Customer"),
_T("user1"),
_T(""),
adOpenUnspecified);
but dont u have to specify a "database" name in addition to "Customer" table?
QUESTION: It's using SQL server based security. what about NT based login?
Thanks
norm
norm
|
|
|
|
|
norm wrote:
but dont u have to specify a "database" name in addition to "Customer" table?
It's a smart pointer to a COM object, it's easy to create, with the __uuidof stuff, and it free's itself.
norm wrote:
why do we need a "connection pointer object" as opposed to a "connection object"
I *believe* that a username/password combination can be associated with only one database, therefore it selects it for you.
norm wrote:
It's using SQL server based security. what about NT based login?
How do you mean ? Once two machines are online and able to see each other, no login is necessarily required between them. Therefore the database has it's own security also, so it can validate users itself.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
<quote>
norm wrote:
It's using SQL server based security. what about NT based login?
How do you mean ? Once two machines are online and able to see each other, no login is necessarily required between them. Therefore the database has it's own security also, so it can validate users itself.
<end quote="">
there's two type of account that u can create with SQL server:
1. SQL server account (user name + passwd combination: transmitted in plain text over the wire)
2. NT based authentication (SQL grant access to a user based on the session/NT login: better security)
and with option 2: NT based authetication, u dont need to send passwd as Open argument. But format? how exactly do u call Open method with NT based login?
norm
|
|
|
|
|
Ah - that I don't know. I'd guess you don't need to specify anything, it will use the username and password you logged into your NT account with. That's how NT->win98 works, NT asks W98 for the username and password logged in.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thanks anyway, i got a lot done with yr help in the last two days.
anyway, i read it before. u do it with Open method ... but i just cant remember exactly how...
but i think one video presentation from MSDN about SQL server security has this... in a powerpoint presentation that comes with the presentation...
i think the presentation is about SSL and SQL server... will check on that and get back to u if i can find it.
norm
|
|
|
|
|
found the presntation, it's:
Using Encryption with Microsoft SQL Server 2000
Kevin McDonnell Technical Lead SQL Server Support Microsoft Corporation
However, it just tells u that...:
Requires MDAC 2.6 or later to be installed
Does not require SQL Server 2000 Tools
Programmers can request SSL encryption in their connection string
ODBC : Encrypt = Yes
Oledb : Use Encryption for Data = True
The focus is on setting up the webserver certificate so that your SQL server and client can encrypt the traffic... but there's got to be a way to connect to a database using NT based login... i will check MSDN now.
anyway, if u want the file, send me an email or something. it's like...450kB
norm
|
|
|
|
|
"INF: Authentication Methods for Connections to SQL Server in Active Server Pages"
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q247931&
i am guessing: just leave out user and password in yr connection string. i need to do a few tests to confirm this
norm
|
|
|
|
|
can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ??
code fragment would be welcome.
and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE??
thanks
norm
|
|
|
|
|
norm wrote:
can i programatically generate a GUID to use as the "name" of "named shared memory" created by call to CreateFileMapping(..) ??
CoCreateGuid() will do it
norm wrote:
and if I want to create "no-name" file mapping, how can I communicate the handle to the file mapping object to a separate process? WM_COPYDATE??
Yes, this means you have to use some other IPC channel to send the HANDLE to the target process. WM_COPYDATA is one idea, if the first process creates the second one, you could also use handle inheritance.
However, a named object is usually the most convinient solution.
BTW: I recommend to use not only a GUID for the name, but also a "human readable" part (somthing like My_app_shared_data_63dcc4b9-b122-4337-b897-88f6a7f49f3f ). This would make it much easier for you and others to find your section in tools like Process Explorer and other debugging tools.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
thanks for the feedback first of all, but i dont understand the whole issue about handle inheritance. u can set the some flags in security attribute when u create the handle and when u CreateProcess. but the child process still have no idea what the handle is!? the child process has the right to inherit, but it still doesnt know what to inherit until the parent process send the handle via mechanism such as WM_COPYDATA??
norm
|
|
|
|
|
The usual (and most easy) way to pass the inherited handles to a child process is via the command line or environment variables.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
I define this below data in .c file
<br />
CString m_data;<br />
when I compile there are these error message
<br />
error C2065: 'CString' : undeclared identifier<br />
error C2146: syntax error : missing ';' before identifier 'm_data'<br />
error C2065: 'm_data' : undeclared identifier<br />
Do you know how to solve my problem?
Thank you.
|
|
|
|
|
CString can only be used in C++ programs. If you can afford it, change the extension of your file to .cpp .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I created my first ATL COM inprocess server, and successfully invoked methods in a VB client. But when i try to integrate it into my ASP script, I got the following error when pointing the URL at my ASP page:
Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp.
/GenJoin.asp, line 7
My ASP script looks like this:
<% @Language = "VBScript" RUNAT=Server %>
<title>GenSQLJoin
Sub Session_OnStart()
Set SQLJoinEngine = Server.CreateObject("ATLFIRSTPROJLib.MyATLServ") THIS LINE IS CAUSING PROBLEM: Invalid ProgID
...
... other stuff...
...
QUESTION 1: how can i determine the progID for my ATL COM server? To help out:
1. my ATL project name: ATLFIRSTPROJ
2. Class: CMyATLServ
3. Interface: IMyATLServ
As mentioned, I already successfully invoked the server from a VB client:
Private Sub btnAdd_Click()
Dim objTestATL As ATLFIRSTPROJLib.MyATLServ
QUESTION 2:
(a) I dont understand the syntax here. We have class name = CMyATLServ and interface name = IMyATLServ. BUT nothing = MyATLServ
(b) My project name is ATLFIRSTPROJ. What's the "LIB" at the end of "ATLFIRSTPROJLib"?
Set objTestATL = New ATLWhore
Dim lngReturnValue As Long
objTestATL.SomeMethod Me.txtNum1, Me.txtNum2, lngReturnValue
Me.txtNum3.Text = lngReturnValue
End Sub
Thanks!
norm
|
|
|
|
|
The ProgID can be determined both by looking at the registry or looking in your .RGS file
You're probably having a bug in VC 6.0 without any service pack. It had a bug when creating an ATL COM component and the default ProgID of your project probably is ATLFIRSTPROJLib.MyATLServ.1
Apply the Service Pack 5 of Visual C++ to solve this and other bugs.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|