|
Return your instance of ClassA or ClassB polymorphically as an instance of IMyInterface. The whole point of the factory is to provide an instance (no matter what the implementation) of your interface.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
hi all,
how can i list running processes ?
howto start or terminate a process ?
is it possible to manage programs like msn or icq with c# ?
i want to be able to send or receive messages both from icq and msn via a program i code ? and change online / offline status of such programs ?
help please,
thanks in advance,
bye.
|
|
|
|
|
1. Process[] processes = Process.GetProcesses();
2. Process.Start(ProcessStartInfo processStartInfo);
3. If there are API for that program, then the answer yes. Search in codeproject or google.
4. See number 3.
5. See number 3.
|
|
|
|
|
1. To list all running processes
System.Diagnostics.Process[] procs=System.Diagnostics.Process.GetProcesses();
2. To terminate a specific process
procs[0].kill();
3. To manage MSN/ICQ
Of course you can do, but exacyly how, i dont know. But i certainly have seen such apps[ Don't know exactly if they were written in Dot Net or not. Even if they were not, they can be written in C#]
Regards,
Wasif Ehsan
Software Engineer
|
|
|
|
|
i am using c# to develope window based application
in my application i am adding and removing lables in pannel control during
runtime,but in between i am getting a error "cannot create windows handle".
can any one help out
regards
rahul
rahul
|
|
|
|
|
i made a share folder on the server with permission to a local user account not a domain account.
i can access the folder by impersonate domain account through LOGONUSER() function but it fails with the local user account.
how can i impersonate the local user?
the following links is valid for domain account only:
http://www.codeproject.com/useritems/User_Impersonation_in_Ne.asp[^]
yossef elnaggar
|
|
|
|
|
Please examine the following article and send your suggestion to improve the article
http://www.codeproject.com/useritems/SqlQueryInXml.asp
|
|
|
|
|
Suggestions
1) You may want to format your XML and C# code so it is propely indented. Also, removing commented out code is preferable before posting your article.
2) You should read up on "encapsulation" and "Data Abstraction Layers", your article tries both but achieves neither
3) Please dont plug your article in the forums
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I will try to update the article with the second point you mentioned . can u suggest , how and where should i implement encapsulation and d A L concepts in this context . What exactly do you want here , so that i can focus re-writing the code and article in that manner.if possible please be little more descriptive
I appreciate your feedback
thanks a lot!
|
|
|
|
|
Well, by encapsulation I mean that you have defined this XML Schema to store information about your procedures, but then you use the XML DOM directly to read this data. You should consider "encapsulating" this functionality into a class which makes it easier for the user (of this library) to read the settings without any reference to the schema or the XML classes.
Also, this sort of functionality is usually "encapsulated" into a Data Abstraction Layer, where the programmer just issues requests to it, and some data is returned... this subject is huge and I cannot really define a data abstraction layer fully in a post - therefore you need to do some research to properly understand the subject you are writing about.
My initial post was rather harsh, as I personally do not like the forums being used to advertise articles. I also do not wish to discourage you or anyone from writing articles - but you should do a certain amount of research and ensure it is a subject you are reasonably knowledgable about before starting.
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
An article actually explains what the code does. All you've done is post a code snippet out of your project and a small example of how to call it. An article is much more than that. What's the methodology behind the code? Why did you do it this way? Why is it better that something else?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the valuable comments and time for exploring the article, I will update the article in short time . I fully admit with what you have said.
|
|
|
|
|
Maybe we should leave the article discussion to the article pages so that we won't have to redirect ourselves.
Best,
Jun
|
|
|
|
|
Hi there,
I have created a bll and dal of which the dal consumes web services as its datasource.
Getting the XML from the web service I then create a collection of objects representing the entities.
Which I then might bind to say a gridview/datagrid.
The lead developer is saying that surely you are then doing something twice, looping through the xml to create the collection, then when you databind the collection. Looping through it again? And is asking the wisdom in this, keeping in mind performance?
Should performance here be an issue? Would it be better, to use the XML returned and bind the datagrid directly to that in stead of using the BLL and DAL?
Advice please? :P
|
|
|
|
|
if any body have a miniproject on DataGrid in C# then plz explain it to me.
|
|
|
|
|
Hi there,
I am trying to make this work for the past three days but with no success, i also posted this in the vb.net section as well. I have a windows form application with web browser control integrated into it. What i want is that when ever there is some file download request come along i get the url and download it via System.net classes, if the file is a word,excel or power point document i open them in my other form where i have integrated the word/excel/pp. all the rest of bits are working the only thing left is that i don't know how to intercept file download. I know i have to implement idownloadmanager interface but i can't make it work, my the download method of the interface never get called. the sample code is here (it's in vb.net but if i can work in c# as well)
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Browser As AxSHDocVw.AxWebBrowser
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Browser = New AxSHDocVw.AxWebBrowser
CType(Me.Browser, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Browser
'
Me.Browser.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Browser.Enabled = True
Me.Browser.Location = New System.Drawing.Point(8, 8)
Me.Browser.OcxState = CType(resources.GetObject("Browser.OcxState"), System.Windows.Forms.AxHost.State)
Me.Browser.Size = New System.Drawing.Size(360, 304)
Me.Browser.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(376, 318)
Me.Controls.Add(Me.Browser)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.Browser, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As System.Object = "http://my.mindvision.com/~ben/tools/"
Dim o As System.Object = Nothing
Browser.Navigate2(url, o, o, o, o)
SetDownloadManager()
End Sub
Private m_DownloadManagerCookie As System.Int32
Private Sub SetDownloadManager()
Dim ips As COMVB.IProfferService
Dim objBrowser As Object
Dim ispBrowser As COMVB.UCOMIServiceProvider
Dim ip As IntPtr
Try
' Get a handle to the browser ocx
objBrowser = Browser.GetOcx()
ispBrowser = DirectCast(objBrowser, COMVB.UCOMIServiceProvider)
' Query the browser for the IProfferService interface
ip = ispBrowser.QueryService(COMVB.SID_SProfferService, COMVB.IID_IProfferService)
ips = DirectCast(Marshal.GetObjectForIUnknown(ip), COMVB.IProfferService)
' Proffer the new object as the provider of the IHTMLEditHostinterface handler
ips.ProfferService(COMVB.IID_IDownloadManager, New ServiceProvider, m_DownloadManagerCookie)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Class ServiceProvider
Implements COMVB.UCOMIServiceProvider
Public Function QueryService(ByRef guidService As System.Guid, ByRef riid As System.Guid) As IntPtr Implements COMVB.UCOMIServiceProvider.QueryService
If guidService.Equals(COMVB.IID_IDownloadManager) Then
If riid.Equals(COMVB.IID_IDownloadManager) Then
Dim idm As COM.Interfaces.IDownloadManager
idm = New DownloadManager
' idm.Download()
Return GetInterface(idm, COMVB.IID_IDownloadManager)
Else
Return Nothing
End If
Else
Return Nothing
End If
End Function
Public Function GetInterface(ByVal obj As Object, ByRef iid As Guid) As IntPtr
Dim pUnk As IntPtr
Dim pInterface As IntPtr
Dim hr As Integer
pUnk = Marshal.GetIUnknownForObject(obj)
hr = Marshal.QueryInterface(pUnk, iid, pInterface)
If hr < 0 Then
Marshal.ThrowExceptionForHR(hr)
End If
' Marshal.GetHINSTANCE()
' Marshal.Release(pUnk)
Return pInterface
End Function
End Class
Class DownloadManager
Implements COM.Interfaces.IDownloadManager
Public Function Download(ByVal pmk As System.Runtime.InteropServices.UCOMIMoniker, ByVal pbc As System.Runtime.InteropServices.UCOMIBindCtx, ByVal dwBindVerb As System.UInt32, ByVal grfBINDF As Integer, ByVal pBindInfo As System.IntPtr, ByVal pszHeaders As String, ByVal pszRedir As String, ByVal uiCP As System.UInt32) As Integer Implements COM.Interfaces.IDownloadManager.Download
MsgBox("file download event")
Return New System.Int32
End Function
End Class
Class COMVB
' IServiceProvider interface
<comvisible(true), comimport(),guid("6d5140c1-7436-11ce-8034-00aa006009fa"),="" _
interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface UCOMIServiceProvider
Function QueryService(ByRef guidService As Guid, ByRef riid As Guid) As IntPtr
End Interface
' IProfferService interface
<comvisible(true), comimport(),="" guid("cb728b20-f786-11ce-92ad-00aa00a74cd0"),="" _
="" interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface IProfferService
Sub ProfferService(ByRef guidService As Guid, ByVal psp As UCOMIServiceProvider, ByRef cookie As Integer)
Sub RevokeService(ByVal cookie As Integer)
End Interface
Public Shared SID_SProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared IID_IProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared SID_SHTMLEditHost As New Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b")
Public Shared IID_IDownloadManager As New Guid("988934A4-064B-11D3-BB80-00104B35E7F9")
End Class
|
|
|
|
|
Try the VB.Net forum, this is the C# forum.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
i know it is a c# forum but you can implement idownloadmanager in c# as well
|
|
|
|
|
hi cp people!
i still can't found the answer to my question about importing a C++ dll into my C# project...
it's not clear to me ont how to set the value on "EntryPoint=" value when importing dll's
what's exactly do you do when setting the value on the "EntryPoint=" part? let's say i have this dll from an unmanaged C++, when i import it's dll, and there's is a function in it that i want to use, let's say it's function name is MyFunc. do you code like this?
[DllImportAttribute("dllname.dll"), EntryPoint = "MyFunc")]
in order for the function that i want to work?
i'm still new at C#, and this dll importing lessons is taking it's toll on me. hehehe
thanks to all those who will post their replies
regards...
In the land of the blind, the one-eyed man is the king.[^]
|
|
|
|
|
Not sure if this CP article can help, as it's written in C++/CLI, not C#.
Best,
Jun
|
|
|
|
|
Use this (http://www.nirsoft.net/utils/dll_export_viewer.html) to find the entry point of your function. The function name in that list is your EntryPoint. Sometimes is the function name also weird (like this ?ShowHelloWorld.??) Then you must use that weird charachter also to use your dll.
For example, if your dll export viewer show something like this ?ShowHelloWorld.?? then you must write :
[DllImport("dllname.dll"), EntryPoint="?ShowHelloWorld.??"]
private static extern void ShowHelloWorld();
|
|
|
|
|
Hi to all,
Plz, help to develop UDP in C# using Winsock Library. From where I can get a sample code to develop UDP using Winsock Library in C#.
I have develop the code, but it failed to receive data in following code,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MSWinsockLib;
using AxMSWinsockLib;
using System.Net;
using System.Net.Sockets;
namespace @as
{
public partial class Form1 : Form
{
WinsockClass winSockCls;
Object data;
String str;
public Form1()
{
InitializeComponent();
data = new Object();
winSockCls = new WinsockClass();
winSockCls.Close();
winSockCls.DataArrival += new MSWinsockLib.DMSWinsockControlEvents_DataArrivalEventHandler(Socket_DataArrival);
}
private void Form1_Load(object sender, EventArgs e)
{
winSockCls.Protocol = MSWinsockLib.ProtocolConstants.sckUDPProtocol;
winSockCls.RemoteHost = "192.168.0.6";
winSockCls.RemotePort = 12345;
winSockCls.LocalPort = 8080;
str = "Hi Ani";
winSockCls.SendData(str);
}
private void Socket_DataArrival(int bytesTotal)
{
if (winSockCls.State != (short)MSWinsockLib.StateConstants.sckOpen)
return;
winSockCls.GetData(ref data, data.GetType(), bytesTotal);
winSockCls.SendData("AS");
}
}
}
But "GetData()" function is not working. Plz, Help me.
Best Regards & Thanks,
Aniket Salunkhe
|
|
|
|
|
Hi all,
I am working on a chat application in which i want the application to run
on the internet i.e the application should use Http for communication purpose
Any idea about this will be a great help,
Thanks & Regards,
Pramod
|
|
|
|
|
Hello
Even over the internet you can -& should- use TCP/IP for communications.
How about making a WebService that connects all the clients together?
|
|
|
|
|
Thanks!!! for that,
Well can u tell me what technologies are used to create the
MSN messenger and Yahoo messengers?
Thanks & Regards,
Pramod
|
|
|
|
|