|
raesa wrote: Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?
Have you tried WNetGetConnection() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
oops
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
|
I did some digging, and the following code worked for me:
TCHAR szBuf [MAX_PATH];
DWORD dwSize = MAX_PATH;
DWORD dw = WNetGetConnection (_T("p:"), szBuf, &dwSize);
It gave me "\\myserveraddress\sharename" in szBuf.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
|
That was one of the first results in google, but it's using .net namespace functionality, and mapping drives.
So almost the exact opposite of what he needs.
Phew, regained my sense of superiority after replying to the wrong person earlier!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: Phew, regained my sense of superiority after replying to the wrong person earlier!
You can still delete that post and hardly anyone would know.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yeah I didnt see .net I delete previous post.
Now I changed title of my reply.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hamid. wrote: I delete previous post.
No, don't join them!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: Codeproject MVP for C++, I can't believe it's for my lounge posts...
But I may have a superb reason to defy your arrogant assumptions.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Infamy, infamy, they've all got it in fo' me!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All,
Did anyone of u ever faced any similar issue.
One of my template class funciton is overloaded...But after instantiating with a pointer, i'm not able to call the overloaded function.
ex:
template<typename Ty>
class sample
{
public:
typedef Ty& reference;
typedef Ty* pointer;
typedef const Ty* const_pointer;
typedef const Ty& const_reference;
pointer address(reference p_data_r) const
{
return &p_data_r;
}
const_pointer address(const_reference p_data_r) const
{
return &p_data_r;
}
};
int main()
{
sample<int*> sample_obj;
//Calling address with const pointer
const int* iptr=new int();
const int* &const_reference=iptr;
const int**const_pointer = sample_obj.address(const_reference);
return 0;
}
Error Message::
error C2664: 'int *sample<Ty>::address(int &) const' : cannot convert parameter 1 from 'const int *' to 'int &'
1> with
1> [
1> Ty=int *
1> ]
1> Conversion loses qualifiers
Let me know your suggestions...
Thanks alot.
Shakeel
|
|
|
|
|
Nothing to do with overloading. For both overloads, you're trying to pass a value of type const int * & through a parameter of type int * & . The compiler correctly says that it can't convert a const int * & to a int * & because int * & is less qualified.
Here's one way of altering the code so it compiles:
template<typename Ty>
class sample
{
public:
typedef Ty& reference;
typedef Ty* pointer;
typedef const Ty* const_pointer;
typedef const Ty& const_reference;
const_pointer address(const_reference p_data_r) const
{
return &p_data_r;
}
pointer address(reference p_data_r) const
{
return &p_data_r;
}
};
int main()
{
sample<int*> sample_obj;
int* iptr=new int();
int* const &const_reference=iptr;
int* const *const_pointer = sample_obj.address(const_reference);
return 0;
} The position of const within a type declaration has a significant impact on the type you end up declaring:
const int* and int const* both mean pointer to const int - i.e.you can alter the pointer, but not the int it points at.
int * const means constant pointer to integer - i.e. you cannot alter the pointer, but you can alter the int it points at.
|
|
|
|
|
That's an interesting question! The issue is that contrary to what one might expect, typedef const Ty* const_pointer does not translate to typedef const int** const_pointer when Ty is int . Instead, it translates to typedef int * const * const_pointer . Consequently, the following code does compile with VC9.
template <typename T>
class Sample
{
public:
typedef const T* const_pointer;
typedef const T& const_reference;
const_pointer address( const_reference ref ) const
{
return &ref;
}
};
int main()
{
Sample<int*> s1;
int val = 10;
int * const pval = &val;
int * const & ref = pval;
int * const * p = s1.address( ref );
return 0;
}
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
When to delete ILayer is Initiated in the below case
ABC::ABC
(
CScope_i* scope
):
AsObject(scope),
itsSppAst(new ILayer::Ast(scope->cppScope().Handle()))
{
//
}
|
|
|
|
|
ptr_Electron wrote: When to delete ILayer is Initiated in the below case
What ? You mean you want to know how to delete the ILayer instance that was created by new ?
Well, that depends a lot of what itsSppAst is... It becomes the only owner of the pointer so it is the only one that is able to delete it. If you don't have access to this class, then you will need to store a ILayer instance in your ABC class and create itsSppAst later, after you created your ILayer instance (you will need to use new in that case).
BTW, your indentation is awfull, it took me quite some time to understand your code which is rather simple.
|
|
|
|
|
This question makes little sense. Please elaborate.
--
gleat
http://blogorama.nerdworks.in[ ^]
-- Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG
|
|
|
|
|
Actually there was some memory leak in the application, I am just go thought the code manually to find them, well on my way, I found a new, so just want to know, wheather I sould care it or neglact it
|
|
|
|
|
The rule is extremly simple: if you want to avoid memory leaks, for each call to new, you should have a corresponding call to delete (the same with new[] and delete[]).
|
|
|
|
|
Thanks, But my question is, does the same work for, in the above mentioned case of new, if yes, how can I do that
|
|
|
|
|
Of course, why would that be different ? You create an object using new, so you must delete it using delete, that's it.
Didn't you read my first reply ? I explained you there how to do that.
|
|
|
|
|
Hi all,
i m using progress.when i run my application its display in blue color .
i want when i run application on XP or Vista OS the progress bar looks like xp prgressbar or vista style progress bar.
please help me for this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote: i want when i run application on XP...the progress bar looks like xp prgressbar...
Are you referring to the PBS_SMOOTH style?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I have a legacy C app which uses FFmpeg APIs.
I'm trying to update it, I want to write a UI in C# and keep the core in C.
So, i'm dabbling in C++/CLI for the first time.
It's my understanding that I can create a managed class wrapper, and have managed methods which take managed parameters, convert them as necessary to unmanaged equivalents (with System.Runtime.InteropServices.Marshal methods), do the work in native C, and then convert outputs from unmanaged to managed types for return.
However, I'm stuck at the start. I've created a class like this:-
ref class FFmpegCap
{
public:
FFmpegCap(String^ inputVideo);
protected:
AVFormatContext *m_pFormatContext;
};
In my constructor, i need to call a C FFmpeg function to initialise the library, one of the parameters it requires is of type AVFormatContext ** . So, I call this function as follows:-
if (av_open_input_file(&m_pFormatContext, pInputVideo ,NULL,0,NULL) != 0)
{
}
However, this fails to compile; error C2664: 'av_open_input_file' : cannot convert parameter 1 from 'cli::interior_ptr<type>' to 'AVFormatContext **'
It seems that the & operator is not doing what I expect of it!
Any pointers?
Thanks
Jon
|
|
|
|
|
There is a C++/CLI forum where you may get faster answers.
Then again, one of the other people here may be typing an answer at the same time as me...
Good luck,
Iain
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|